forked from PagerDuty/terraform-provider-pagerduty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_pagerduty_ruleset_rule_test.go
38 lines (32 loc) · 1.15 KB
/
import_pagerduty_ruleset_rule_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package pagerduty
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
func TestAccPagerDutyRulesetRule_import(t *testing.T) {
ruleset := fmt.Sprintf("tf-%s", acctest.RandString(5))
teamName := fmt.Sprintf("tf-%s", acctest.RandString(5))
rule := fmt.Sprintf("tf-%s", acctest.RandString(5))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutyRulesetRuleDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyRulesetRuleConfig(ruleset, teamName, rule),
},
{
ResourceName: "pagerduty_ruleset_rule.foo",
ImportStateIdFunc: testAccCheckPagerDutyRulesetRuleID,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
func testAccCheckPagerDutyRulesetRuleID(s *terraform.State) (string, error) {
return fmt.Sprintf("%v.%v", s.RootModule().Resources["pagerduty_ruleset.foo"].Primary.ID, s.RootModule().Resources["pagerduty_ruleset_rule.foo"].Primary.ID), nil
}