forked from PagerDuty/terraform-provider-pagerduty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_source_pagerduty_extension_schema_test.go
57 lines (46 loc) · 1.48 KB
/
data_source_pagerduty_extension_schema_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package pagerduty
import (
"fmt"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
func TestAccDataSourcePagerDutyExtensionSchema_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckPagerDutyScheduleDestroy,
Steps: []resource.TestStep{
{
Config: testAccDataSourcePagerDutyExtensionSchemaConfig,
Check: resource.ComposeTestCheckFunc(
testAccDataSourcePagerDutyExtensionSchema("data.pagerduty_extension_schema.foo"),
),
},
},
})
}
func testAccDataSourcePagerDutyExtensionSchema(n string) resource.TestCheckFunc {
return func(s *terraform.State) error {
r := s.RootModule().Resources[n]
a := r.Primary.Attributes
if a["id"] == "" {
return fmt.Errorf("Expected to get an Extension Schema ID from PagerDuty")
}
if a["id"] != "PD8SURB" {
return fmt.Errorf("Expected the Slack Extension Schema ID to be: PD8SURB, but got: %s", a["id"])
}
if a["name"] != "Slack" {
return fmt.Errorf("Expected the Slack Extension Schema Name to be: Slack, but got: %s", a["name"])
}
if a["type"] != "extension_schema" {
return fmt.Errorf("Expected the Slack Extension Schema Type to be: extension_schema, but got: %s", a["type"])
}
return nil
}
}
const testAccDataSourcePagerDutyExtensionSchemaConfig = `
data "pagerduty_extension_schema" "foo" {
name = "slack"
}
`