aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPaul Stack <public@paulstack.co.uk>2017-02-15 23:29:05 +0000
committerGitHub <noreply@github.com>2017-02-15 23:29:05 +0000
commit90db3fb0ba1aff53f83ece8f5d62f56943ed090e (patch)
tree0a0eb730ee6a18d683d658d463e3f07b9107d1a4
parent6ad7af97bbcfa90a6798dd78ae19adfcef179bdc (diff)
downloadterraform-provider-statuscake-90db3fb0ba1aff53f83ece8f5d62f56943ed090e.tar.gz
terraform-provider-statuscake-90db3fb0ba1aff53f83ece8f5d62f56943ed090e.tar.zst
terraform-provider-statuscake-90db3fb0ba1aff53f83ece8f5d62f56943ed090e.zip
provider/statuscake: Add support for Port in statuscake_test (#11966)
Fixes: #11923 This required the upstream library to have a PR accepted
-rw-r--r--resource_statuscaketest.go28
-rw-r--r--resource_statuscaketest_test.go38
2 files changed, 54 insertions, 12 deletions
diff --git a/resource_statuscaketest.go b/resource_statuscaketest.go
index bc05364..dbc15c9 100644
--- a/resource_statuscaketest.go
+++ b/resource_statuscaketest.go
@@ -18,50 +18,55 @@ func resourceStatusCakeTest() *schema.Resource {
18 Read: ReadTest, 18 Read: ReadTest,
19 19
20 Schema: map[string]*schema.Schema{ 20 Schema: map[string]*schema.Schema{
21 "test_id": &schema.Schema{ 21 "test_id": {
22 Type: schema.TypeString, 22 Type: schema.TypeString,
23 Computed: true, 23 Computed: true,
24 }, 24 },
25 25
26 "website_name": &schema.Schema{ 26 "website_name": {
27 Type: schema.TypeString, 27 Type: schema.TypeString,
28 Required: true, 28 Required: true,
29 }, 29 },
30 30
31 "website_url": &schema.Schema{ 31 "website_url": {
32 Type: schema.TypeString, 32 Type: schema.TypeString,
33 Required: true, 33 Required: true,
34 }, 34 },
35 35
36 "contact_id": &schema.Schema{ 36 "contact_id": {
37 Type: schema.TypeInt, 37 Type: schema.TypeInt,
38 Optional: true, 38 Optional: true,
39 }, 39 },
40 40
41 "check_rate": &schema.Schema{ 41 "check_rate": {
42 Type: schema.TypeInt, 42 Type: schema.TypeInt,
43 Optional: true, 43 Optional: true,
44 Default: 300, 44 Default: 300,
45 }, 45 },
46 46
47 "test_type": &schema.Schema{ 47 "test_type": {
48 Type: schema.TypeString, 48 Type: schema.TypeString,
49 Required: true, 49 Required: true,
50 }, 50 },
51 51
52 "paused": &schema.Schema{ 52 "paused": {
53 Type: schema.TypeBool, 53 Type: schema.TypeBool,
54 Optional: true, 54 Optional: true,
55 Default: false, 55 Default: false,
56 }, 56 },
57 57
58 "timeout": &schema.Schema{ 58 "timeout": {
59 Type: schema.TypeInt, 59 Type: schema.TypeInt,
60 Optional: true, 60 Optional: true,
61 Default: 40, 61 Default: 40,
62 }, 62 },
63 63
64 "confirmations": &schema.Schema{ 64 "confirmations": {
65 Type: schema.TypeInt,
66 Optional: true,
67 },
68
69 "port": {
65 Type: schema.TypeInt, 70 Type: schema.TypeInt,
66 Optional: true, 71 Optional: true,
67 }, 72 },
@@ -81,6 +86,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
81 Timeout: d.Get("timeout").(int), 86 Timeout: d.Get("timeout").(int),
82 ContactID: d.Get("contact_id").(int), 87 ContactID: d.Get("contact_id").(int),
83 Confirmation: d.Get("confirmations").(int), 88 Confirmation: d.Get("confirmations").(int),
89 Port: d.Get("port").(int),
84 } 90 }
85 91
86 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string)) 92 log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@@ -144,6 +150,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
144 d.Set("timeout", testResp.Timeout) 150 d.Set("timeout", testResp.Timeout)
145 d.Set("contact_id", testResp.ContactID) 151 d.Set("contact_id", testResp.ContactID)
146 d.Set("confirmations", testResp.Confirmation) 152 d.Set("confirmations", testResp.Confirmation)
153 d.Set("port", testResp.Port)
147 154
148 return nil 155 return nil
149} 156}
@@ -183,5 +190,8 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
183 if v, ok := d.GetOk("confirmations"); ok { 190 if v, ok := d.GetOk("confirmations"); ok {
184 test.Confirmation = v.(int) 191 test.Confirmation = v.(int)
185 } 192 }
193 if v, ok := d.GetOk("port"); ok {
194 test.Port = v.(int)
195 }
186 return test 196 return test
187} 197}
diff --git a/resource_statuscaketest_test.go b/resource_statuscaketest_test.go
index 1def4e3..17940ed 100644
--- a/resource_statuscaketest_test.go
+++ b/resource_statuscaketest_test.go
@@ -18,7 +18,7 @@ func TestAccStatusCake_basic(t *testing.T) {
18 Providers: testAccProviders, 18 Providers: testAccProviders,
19 CheckDestroy: testAccTestCheckDestroy(&test), 19 CheckDestroy: testAccTestCheckDestroy(&test),
20 Steps: []resource.TestStep{ 20 Steps: []resource.TestStep{
21 resource.TestStep{ 21 {
22 Config: testAccTestConfig_basic, 22 Config: testAccTestConfig_basic,
23 Check: resource.ComposeTestCheckFunc( 23 Check: resource.ComposeTestCheckFunc(
24 testAccTestCheckExists("statuscake_test.google", &test), 24 testAccTestCheckExists("statuscake_test.google", &test),
@@ -29,6 +29,25 @@ func TestAccStatusCake_basic(t *testing.T) {
29 }) 29 })
30} 30}
31 31
32func TestAccStatusCake_tcp(t *testing.T) {
33 var test statuscake.Test
34
35 resource.Test(t, resource.TestCase{
36 PreCheck: func() { testAccPreCheck(t) },
37 Providers: testAccProviders,
38 CheckDestroy: testAccTestCheckDestroy(&test),
39 Steps: []resource.TestStep{
40 {
41 Config: testAccTestConfig_tcp,
42 Check: resource.ComposeTestCheckFunc(
43 testAccTestCheckExists("statuscake_test.google", &test),
44 testAccTestCheckAttributes("statuscake_test.google", &test),
45 ),
46 },
47 },
48 })
49}
50
32func TestAccStatusCake_withUpdate(t *testing.T) { 51func TestAccStatusCake_withUpdate(t *testing.T) {
33 var test statuscake.Test 52 var test statuscake.Test
34 53
@@ -37,14 +56,14 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
37 Providers: testAccProviders, 56 Providers: testAccProviders,
38 CheckDestroy: testAccTestCheckDestroy(&test), 57 CheckDestroy: testAccTestCheckDestroy(&test),
39 Steps: []resource.TestStep{ 58 Steps: []resource.TestStep{
40 resource.TestStep{ 59 {
41 Config: testAccTestConfig_basic, 60 Config: testAccTestConfig_basic,
42 Check: resource.ComposeTestCheckFunc( 61 Check: resource.ComposeTestCheckFunc(
43 testAccTestCheckExists("statuscake_test.google", &test), 62 testAccTestCheckExists("statuscake_test.google", &test),
44 ), 63 ),
45 }, 64 },
46 65
47 resource.TestStep{ 66 {
48 Config: testAccTestConfig_update, 67 Config: testAccTestConfig_update,
49 Check: resource.ComposeTestCheckFunc( 68 Check: resource.ComposeTestCheckFunc(
50 testAccTestCheckExists("statuscake_test.google", &test), 69 testAccTestCheckExists("statuscake_test.google", &test),
@@ -163,3 +182,16 @@ resource "statuscake_test" "google" {
163 paused = true 182 paused = true
164} 183}
165` 184`
185
186const testAccTestConfig_tcp = `
187resource "statuscake_test" "google" {
188 website_name = "google.com"
189 website_url = "www.google.com"
190 test_type = "TCP"
191 check_rate = 300
192 timeout = 10
193 contact_id = 12345
194 confirmations = 1
195 port = 80
196}
197`