diff options
author | Mat Schaffer <mat@schaffer.me> | 2018-02-01 16:07:31 +0900 |
---|---|---|
committer | Mat Schaffer <mat@schaffer.me> | 2018-02-01 16:07:31 +0900 |
commit | aa4f9726b4fd3cc624fe5784b033840a6c92c84c (patch) | |
tree | e426709f68b0cae06577856f4e6e03226d1acc94 /statuscake | |
parent | c9458806c73b69e6af47eddd83391197b6d2a641 (diff) | |
download | terraform-provider-statuscake-aa4f9726b4fd3cc624fe5784b033840a6c92c84c.tar.gz terraform-provider-statuscake-aa4f9726b4fd3cc624fe5784b033840a6c92c84c.tar.zst terraform-provider-statuscake-aa4f9726b4fd3cc624fe5784b033840a6c92c84c.zip |
Parameterize the contact ID used for acceptance testing
This allowed me to run acceptance tests on my own account.
Diffstat (limited to 'statuscake')
-rw-r--r-- | statuscake/provider_test.go | 15 | ||||
-rw-r--r-- | statuscake/resource_statuscaketest_test.go | 10 |
2 files changed, 20 insertions, 5 deletions
diff --git a/statuscake/provider_test.go b/statuscake/provider_test.go index 83045d0..81d5888 100644 --- a/statuscake/provider_test.go +++ b/statuscake/provider_test.go | |||
@@ -1,7 +1,9 @@ | |||
1 | package statuscake | 1 | package statuscake |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | ||
4 | "os" | 5 | "os" |
6 | "strconv" | ||
5 | "testing" | 7 | "testing" |
6 | 8 | ||
7 | "github.com/hashicorp/terraform/helper/schema" | 9 | "github.com/hashicorp/terraform/helper/schema" |
@@ -10,12 +12,25 @@ import ( | |||
10 | 12 | ||
11 | var testAccProviders map[string]terraform.ResourceProvider | 13 | var testAccProviders map[string]terraform.ResourceProvider |
12 | var testAccProvider *schema.Provider | 14 | var testAccProvider *schema.Provider |
15 | var testContactGroupId int | ||
13 | 16 | ||
14 | func init() { | 17 | func init() { |
15 | testAccProvider = Provider().(*schema.Provider) | 18 | testAccProvider = Provider().(*schema.Provider) |
16 | testAccProviders = map[string]terraform.ResourceProvider{ | 19 | testAccProviders = map[string]terraform.ResourceProvider{ |
17 | "statuscake": testAccProvider, | 20 | "statuscake": testAccProvider, |
18 | } | 21 | } |
22 | |||
23 | if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v == "" { | ||
24 | fmt.Println("STATUSCAKE_TEST_CONTACT_GROUP_ID must be set for acceptance tests") | ||
25 | os.Exit(1) | ||
26 | } else { | ||
27 | id, err := strconv.Atoi(v) | ||
28 | if err != nil { | ||
29 | fmt.Println("STATUSCAKE_TEST_CONTACT_GROUP_ID must be a valid int") | ||
30 | os.Exit(1) | ||
31 | } | ||
32 | testContactGroupId = id | ||
33 | } | ||
19 | } | 34 | } |
20 | 35 | ||
21 | func TestProvider(t *testing.T) { | 36 | func TestProvider(t *testing.T) { |
diff --git a/statuscake/resource_statuscaketest_test.go b/statuscake/resource_statuscaketest_test.go index b727e92..ea69756 100644 --- a/statuscake/resource_statuscaketest_test.go +++ b/statuscake/resource_statuscaketest_test.go | |||
@@ -19,7 +19,7 @@ func TestAccStatusCake_basic(t *testing.T) { | |||
19 | CheckDestroy: testAccTestCheckDestroy(&test), | 19 | CheckDestroy: testAccTestCheckDestroy(&test), |
20 | Steps: []resource.TestStep{ | 20 | Steps: []resource.TestStep{ |
21 | { | 21 | { |
22 | Config: testAccTestConfig_basic, | 22 | Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId), |
23 | Check: resource.ComposeTestCheckFunc( | 23 | Check: resource.ComposeTestCheckFunc( |
24 | testAccTestCheckExists("statuscake_test.google", &test), | 24 | testAccTestCheckExists("statuscake_test.google", &test), |
25 | testAccTestCheckAttributes("statuscake_test.google", &test), | 25 | testAccTestCheckAttributes("statuscake_test.google", &test), |
@@ -38,7 +38,7 @@ func TestAccStatusCake_tcp(t *testing.T) { | |||
38 | CheckDestroy: testAccTestCheckDestroy(&test), | 38 | CheckDestroy: testAccTestCheckDestroy(&test), |
39 | Steps: []resource.TestStep{ | 39 | Steps: []resource.TestStep{ |
40 | { | 40 | { |
41 | Config: testAccTestConfig_tcp, | 41 | Config: fmt.Sprintf(testAccTestConfig_tcp, testContactGroupId), |
42 | Check: resource.ComposeTestCheckFunc( | 42 | Check: resource.ComposeTestCheckFunc( |
43 | testAccTestCheckExists("statuscake_test.google", &test), | 43 | testAccTestCheckExists("statuscake_test.google", &test), |
44 | testAccTestCheckAttributes("statuscake_test.google", &test), | 44 | testAccTestCheckAttributes("statuscake_test.google", &test), |
@@ -57,7 +57,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) { | |||
57 | CheckDestroy: testAccTestCheckDestroy(&test), | 57 | CheckDestroy: testAccTestCheckDestroy(&test), |
58 | Steps: []resource.TestStep{ | 58 | Steps: []resource.TestStep{ |
59 | { | 59 | { |
60 | Config: testAccTestConfig_basic, | 60 | Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId), |
61 | Check: resource.ComposeTestCheckFunc( | 61 | Check: resource.ComposeTestCheckFunc( |
62 | testAccTestCheckExists("statuscake_test.google", &test), | 62 | testAccTestCheckExists("statuscake_test.google", &test), |
63 | ), | 63 | ), |
@@ -240,7 +240,7 @@ resource "statuscake_test" "google" { | |||
240 | test_type = "HTTP" | 240 | test_type = "HTTP" |
241 | check_rate = 300 | 241 | check_rate = 300 |
242 | timeout = 10 | 242 | timeout = 10 |
243 | contact_id = 43402 | 243 | contact_id = %d |
244 | confirmations = 1 | 244 | confirmations = 1 |
245 | trigger_rate = 10 | 245 | trigger_rate = 10 |
246 | } | 246 | } |
@@ -284,7 +284,7 @@ resource "statuscake_test" "google" { | |||
284 | test_type = "TCP" | 284 | test_type = "TCP" |
285 | check_rate = 300 | 285 | check_rate = 300 |
286 | timeout = 10 | 286 | timeout = 10 |
287 | contact_id = 43402 | 287 | contact_id = %d |
288 | confirmations = 1 | 288 | confirmations = 1 |
289 | port = 80 | 289 | port = 80 |
290 | } | 290 | } |