aboutsummaryrefslogtreecommitdiffhomepage
path: root/statuscake/resource_statuscaketest_test.go
diff options
context:
space:
mode:
authorMat Schaffer <mat@schaffer.me>2018-02-01 22:53:16 +0900
committerMat Schaffer <mat@schaffer.me>2018-02-01 22:53:16 +0900
commit7d96831373ec571cf0d7bcd930fd6118dc509fc2 (patch)
treef6c684360c490eb61e09b5f69fedc69a29fe38d1 /statuscake/resource_statuscaketest_test.go
parent85e124eb0c7b262ff9c486abe9662f515f47fc5b (diff)
downloadterraform-provider-statuscake-7d96831373ec571cf0d7bcd930fd6118dc509fc2.tar.gz
terraform-provider-statuscake-7d96831373ec571cf0d7bcd930fd6118dc509fc2.tar.zst
terraform-provider-statuscake-7d96831373ec571cf0d7bcd930fd6118dc509fc2.zip
Move template interpolation deeper into acceptance tests
Since it was failing `make test` on travis. Must be a better way to go about this, but I couldn't come up with a better way that defaulting the value to avoid the error when running non-acceptance tests.
Diffstat (limited to 'statuscake/resource_statuscaketest_test.go')
-rw-r--r--statuscake/resource_statuscaketest_test.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/statuscake/resource_statuscaketest_test.go b/statuscake/resource_statuscaketest_test.go
index da3a349..8bcbb36 100644
--- a/statuscake/resource_statuscaketest_test.go
+++ b/statuscake/resource_statuscaketest_test.go
@@ -2,6 +2,7 @@ package statuscake
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os"
5 "strconv" 6 "strconv"
6 "testing" 7 "testing"
7 8
@@ -19,7 +20,7 @@ func TestAccStatusCake_basic(t *testing.T) {
19 CheckDestroy: testAccTestCheckDestroy(&test), 20 CheckDestroy: testAccTestCheckDestroy(&test),
20 Steps: []resource.TestStep{ 21 Steps: []resource.TestStep{
21 { 22 {
22 Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId), 23 Config: interpolateTerraformTemplate(testAccTestConfig_basic),
23 Check: resource.ComposeTestCheckFunc( 24 Check: resource.ComposeTestCheckFunc(
24 testAccTestCheckExists("statuscake_test.google", &test), 25 testAccTestCheckExists("statuscake_test.google", &test),
25 testAccTestCheckAttributes("statuscake_test.google", &test), 26 testAccTestCheckAttributes("statuscake_test.google", &test),
@@ -38,7 +39,7 @@ func TestAccStatusCake_tcp(t *testing.T) {
38 CheckDestroy: testAccTestCheckDestroy(&test), 39 CheckDestroy: testAccTestCheckDestroy(&test),
39 Steps: []resource.TestStep{ 40 Steps: []resource.TestStep{
40 { 41 {
41 Config: fmt.Sprintf(testAccTestConfig_tcp, testContactGroupId), 42 Config: interpolateTerraformTemplate(testAccTestConfig_tcp),
42 Check: resource.ComposeTestCheckFunc( 43 Check: resource.ComposeTestCheckFunc(
43 testAccTestCheckExists("statuscake_test.google", &test), 44 testAccTestCheckExists("statuscake_test.google", &test),
44 testAccTestCheckAttributes("statuscake_test.google", &test), 45 testAccTestCheckAttributes("statuscake_test.google", &test),
@@ -57,7 +58,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
57 CheckDestroy: testAccTestCheckDestroy(&test), 58 CheckDestroy: testAccTestCheckDestroy(&test),
58 Steps: []resource.TestStep{ 59 Steps: []resource.TestStep{
59 { 60 {
60 Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId), 61 Config: interpolateTerraformTemplate(testAccTestConfig_basic),
61 Check: resource.ComposeTestCheckFunc( 62 Check: resource.ComposeTestCheckFunc(
62 testAccTestCheckExists("statuscake_test.google", &test), 63 testAccTestCheckExists("statuscake_test.google", &test),
63 ), 64 ),
@@ -212,6 +213,19 @@ func testAccTestCheckDestroy(test *statuscake.Test) resource.TestCheckFunc {
212 } 213 }
213} 214}
214 215
216func interpolateTerraformTemplate(template string) string {
217 testContactGroupId := 43402
218
219 if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v != "" {
220 id, err := strconv.Atoi(v)
221 if err == nil {
222 testContactGroupId = id
223 }
224 }
225
226 return fmt.Sprintf(template, testContactGroupId)
227}
228
215const testAccTestConfig_basic = ` 229const testAccTestConfig_basic = `
216resource "statuscake_test" "google" { 230resource "statuscake_test" "google" {
217 website_name = "google.com" 231 website_name = "google.com"