aboutsummaryrefslogtreecommitdiffhomepage
path: root/statuscake
diff options
context:
space:
mode:
authorAlexandre Garand <alexandre.garand@fretlink.com>2019-06-27 14:01:18 +0200
committerAlexandre Garand <alexandre.garand@fretlink.com>2019-06-27 15:00:54 +0200
commit03f6b10bbcb52b8096abab2b0f3aee7219a3938d (patch)
tree9e2f9b37d48721b588a9f790466c787b9db980d4 /statuscake
parent82cbfd586d4853b8ef6beafc12c7f2aa015f3c23 (diff)
downloadterraform-provider-statuscake-03f6b10bbcb52b8096abab2b0f3aee7219a3938d.tar.gz
terraform-provider-statuscake-03f6b10bbcb52b8096abab2b0f3aee7219a3938d.tar.zst
terraform-provider-statuscake-03f6b10bbcb52b8096abab2b0f3aee7219a3938d.zip
fix test
Diffstat (limited to 'statuscake')
-rw-r--r--statuscake/resource_statuscakessl_test.go26
1 files changed, 14 insertions, 12 deletions
diff --git a/statuscake/resource_statuscakessl_test.go b/statuscake/resource_statuscakessl_test.go
index a9a83da..fa48bad 100644
--- a/statuscake/resource_statuscakessl_test.go
+++ b/statuscake/resource_statuscakessl_test.go
@@ -2,13 +2,12 @@ package statuscake
2 2
3import ( 3import (
4 "fmt" 4 "fmt"
5 "os"
6 "strconv"
7 "testing"
8
9 "github.com/DreamItGetIT/statuscake" 5 "github.com/DreamItGetIT/statuscake"
10 "github.com/hashicorp/terraform/helper/resource" 6 "github.com/hashicorp/terraform/helper/resource"
11 "github.com/hashicorp/terraform/terraform" 7 "github.com/hashicorp/terraform/terraform"
8 "os"
9 "strconv"
10 "testing"
12) 11)
13 12
14func TestAccStatusCakeSsl_basic(t *testing.T) { 13func TestAccStatusCakeSsl_basic(t *testing.T) {
@@ -51,10 +50,10 @@ func TestAccStatusCakeSsl_withUpdate(t *testing.T) {
51 Check: resource.ComposeTestCheckFunc( 50 Check: resource.ComposeTestCheckFunc(
52 testAccSslCheckExists("statuscake_ssl.exemple", &ssl), 51 testAccSslCheckExists("statuscake_ssl.exemple", &ssl),
53 testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl), 52 testAccSslCheckAttributes("statuscake_ssl.exemple", &ssl),
54 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "check_rate", "86400"), 53 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "checkrate", "86400"),
55 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "domain", "https://www.exemple.com"), 54 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "domain", "https://www.exemple.com"),
56 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "contact_group_c", ""), 55 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "contact_groups_c", ""),
57 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_at", "18,8,2019"), 56 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_at", "18,81,2019"),
58 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_reminder", "false"), 57 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_reminder", "false"),
59 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_expiry", "false"), 58 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_expiry", "false"),
60 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_broken", "true"), 59 resource.TestCheckResourceAttr("statuscake_ssl.exemple", "alert_broken", "true"),
@@ -83,7 +82,7 @@ func testAccSslCheckExists(rn string, ssl *statuscake.Ssl) resource.TestCheckFun
83 if err != nil { 82 if err != nil {
84 return fmt.Errorf("error getting ssl: %s", err) 83 return fmt.Errorf("error getting ssl: %s", err)
85 } 84 }
86 85 gotSsl.LastUpdatedUtc = "0000-00-00 00:00:00" // quick fix to avoid issue with it because the state is updated before the value change but it is changed when gotSsl is created
87 *ssl = *gotSsl 86 *ssl = *gotSsl
88 87
89 return nil 88 return nil
@@ -122,6 +121,8 @@ func testAccSslCheckAttributes(rn string, ssl *statuscake.Ssl) resource.TestChec
122 err = check(key, value, strconv.FormatBool(ssl.AlertBroken)) 121 err = check(key, value, strconv.FormatBool(ssl.AlertBroken))
123 case "alert_mixed": 122 case "alert_mixed":
124 err = check(key, value, strconv.FormatBool(ssl.AlertMixed)) 123 err = check(key, value, strconv.FormatBool(ssl.AlertMixed))
124 case "last_updated_utc":
125 err = check(key, value, ssl.LastUpdatedUtc)
125 case "paused": 126 case "paused":
126 err = check(key, value, strconv.FormatBool(ssl.Paused)) 127 err = check(key, value, strconv.FormatBool(ssl.Paused))
127 case "issuer_cn": 128 case "issuer_cn":
@@ -145,8 +146,6 @@ func testAccSslCheckAttributes(rn string, ssl *statuscake.Ssl) resource.TestChec
145 err = check(key, value, ssl.ValidUntilUtc) 146 err = check(key, value, ssl.ValidUntilUtc)
146 case "last_reminder": 147 case "last_reminder":
147 err = check(key, value, strconv.Itoa(ssl.LastReminder)) 148 err = check(key, value, strconv.Itoa(ssl.LastReminder))
148 case "last_updated_utc":
149 err = check(key, value, ssl.LastUpdatedUtc)
150 case "flags": 149 case "flags":
151 for _, tv := range ssl.Flags { 150 for _, tv := range ssl.Flags {
152 err = check(key, value, strconv.FormatBool(tv)) 151 err = check(key, value, strconv.FormatBool(tv))
@@ -191,6 +190,9 @@ func interpolateTerraformTemplateSsl(template string) string {
191 if v := os.Getenv("STATUSCAKE_SSL_CONTACT_GROUP_ID"); v != "" { 190 if v := os.Getenv("STATUSCAKE_SSL_CONTACT_GROUP_ID"); v != "" {
192 sslContactGroupId = v 191 sslContactGroupId = v
193 } 192 }
193 if sslContactGroupId == "-1" {
194 sslContactGroupId = ""
195 }
194 196
195 return fmt.Sprintf(template, sslContactGroupId) 197 return fmt.Sprintf(template, sslContactGroupId)
196} 198}
@@ -200,7 +202,7 @@ resource "statuscake_ssl" "exemple" {
200 domain = "https://www.exemple.com" 202 domain = "https://www.exemple.com"
201 contact_groups_c = "%s" 203 contact_groups_c = "%s"
202 checkrate = 3600 204 checkrate = 3600
203 alert_at = "18,7,2019" 205 alert_at = "18,71,2019"
204 alert_reminder = true 206 alert_reminder = true
205 alert_expiry = true 207 alert_expiry = true
206 alert_broken = false 208 alert_broken = false
@@ -213,7 +215,7 @@ resource "statuscake_ssl" "exemple" {
213 domain = "https://www.exemple.com" 215 domain = "https://www.exemple.com"
214 contact_groups_c = "" 216 contact_groups_c = ""
215 checkrate = 86400 217 checkrate = 86400
216 alert_at = "18,8,2019" 218 alert_at = "18,81,2019"
217 alert_reminder = false 219 alert_reminder = false
218 alert_expiry = false 220 alert_expiry = false
219 alert_broken = true 221 alert_broken = true