github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/builtin/providers/pagerduty/data_source_pagerduty_vendor_test.go (about) 1 package pagerduty 2 3 import ( 4 "fmt" 5 "testing" 6 7 "github.com/hashicorp/terraform/helper/resource" 8 "github.com/hashicorp/terraform/terraform" 9 ) 10 11 func TestAccPagerDutyVendor_Basic(t *testing.T) { 12 resource.Test(t, resource.TestCase{ 13 PreCheck: func() { testAccPreCheck(t) }, 14 Providers: testAccProviders, 15 CheckDestroy: testAccCheckPagerDutyScheduleDestroy, 16 Steps: []resource.TestStep{ 17 resource.TestStep{ 18 Config: testAccPagerDutyVendorsConfig, 19 Check: resource.ComposeTestCheckFunc( 20 testAccPagerDutyVendors("data.pagerduty_vendor.datadog"), 21 ), 22 }, 23 }, 24 }) 25 } 26 27 func testAccPagerDutyVendors(n string) resource.TestCheckFunc { 28 return func(s *terraform.State) error { 29 30 r := s.RootModule().Resources[n] 31 a := r.Primary.Attributes 32 33 if a["id"] == "" { 34 return fmt.Errorf("Expected to get a vendor ID from PagerDuty") 35 } 36 37 if a["id"] != "PAM4FGS" { 38 return fmt.Errorf("Expected the Datadog Vendor ID to be: PAM4FGS, but got: %s", a["id"]) 39 } 40 41 if a["name"] != "Datadog" { 42 return fmt.Errorf("Expected the Datadog Vendor Name to be: Datadog, but got: %s", a["name"]) 43 } 44 45 if a["type"] != "generic_events_api_inbound_integration" { 46 return fmt.Errorf("Expected the Datadog Vendor Type to be: generic_events_api_inbound_integration, but got: %s", a["type"]) 47 } 48 49 return nil 50 } 51 } 52 53 const testAccPagerDutyVendorsConfig = ` 54 data "pagerduty_vendor" "datadog" { 55 name_regex = "Datadog" 56 } 57 `