]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/commitdiff
provider/statuscake: Add support for Port in statuscake_test (#11966)
authorPaul Stack <public@paulstack.co.uk>
Wed, 15 Feb 2017 23:29:05 +0000 (23:29 +0000)
committerGitHub <noreply@github.com>
Wed, 15 Feb 2017 23:29:05 +0000 (23:29 +0000)
Fixes: #11923
This required the upstream library to have a PR accepted

resource_statuscaketest.go
resource_statuscaketest_test.go

index bc0536420a21fc1350517f7c119eaad670818d5e..dbc15c9fbc84339f91c043199ebffcd3827a94dd 100644 (file)
@@ -18,50 +18,55 @@ func resourceStatusCakeTest() *schema.Resource {
                Read:   ReadTest,
 
                Schema: map[string]*schema.Schema{
-                       "test_id": &schema.Schema{
+                       "test_id": {
                                Type:     schema.TypeString,
                                Computed: true,
                        },
 
-                       "website_name": &schema.Schema{
+                       "website_name": {
                                Type:     schema.TypeString,
                                Required: true,
                        },
 
-                       "website_url": &schema.Schema{
+                       "website_url": {
                                Type:     schema.TypeString,
                                Required: true,
                        },
 
-                       "contact_id": &schema.Schema{
+                       "contact_id": {
                                Type:     schema.TypeInt,
                                Optional: true,
                        },
 
-                       "check_rate": &schema.Schema{
+                       "check_rate": {
                                Type:     schema.TypeInt,
                                Optional: true,
                                Default:  300,
                        },
 
-                       "test_type": &schema.Schema{
+                       "test_type": {
                                Type:     schema.TypeString,
                                Required: true,
                        },
 
-                       "paused": &schema.Schema{
+                       "paused": {
                                Type:     schema.TypeBool,
                                Optional: true,
                                Default:  false,
                        },
 
-                       "timeout": &schema.Schema{
+                       "timeout": {
                                Type:     schema.TypeInt,
                                Optional: true,
                                Default:  40,
                        },
 
-                       "confirmations": &schema.Schema{
+                       "confirmations": {
+                               Type:     schema.TypeInt,
+                               Optional: true,
+                       },
+
+                       "port": {
                                Type:     schema.TypeInt,
                                Optional: true,
                        },
@@ -81,6 +86,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
                Timeout:      d.Get("timeout").(int),
                ContactID:    d.Get("contact_id").(int),
                Confirmation: d.Get("confirmations").(int),
+               Port:         d.Get("port").(int),
        }
 
        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 {
        d.Set("timeout", testResp.Timeout)
        d.Set("contact_id", testResp.ContactID)
        d.Set("confirmations", testResp.Confirmation)
+       d.Set("port", testResp.Port)
 
        return nil
 }
@@ -183,5 +190,8 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
        if v, ok := d.GetOk("confirmations"); ok {
                test.Confirmation = v.(int)
        }
+       if v, ok := d.GetOk("port"); ok {
+               test.Port = v.(int)
+       }
        return test
 }
index 1def4e317945cc0175fda9e9657eaa484a967e68..17940ed873d049efd15869195d564601fbba8165 100644 (file)
@@ -18,7 +18,7 @@ func TestAccStatusCake_basic(t *testing.T) {
                Providers:    testAccProviders,
                CheckDestroy: testAccTestCheckDestroy(&test),
                Steps: []resource.TestStep{
-                       resource.TestStep{
+                       {
                                Config: testAccTestConfig_basic,
                                Check: resource.ComposeTestCheckFunc(
                                        testAccTestCheckExists("statuscake_test.google", &test),
@@ -29,6 +29,25 @@ func TestAccStatusCake_basic(t *testing.T) {
        })
 }
 
+func TestAccStatusCake_tcp(t *testing.T) {
+       var test statuscake.Test
+
+       resource.Test(t, resource.TestCase{
+               PreCheck:     func() { testAccPreCheck(t) },
+               Providers:    testAccProviders,
+               CheckDestroy: testAccTestCheckDestroy(&test),
+               Steps: []resource.TestStep{
+                       {
+                               Config: testAccTestConfig_tcp,
+                               Check: resource.ComposeTestCheckFunc(
+                                       testAccTestCheckExists("statuscake_test.google", &test),
+                                       testAccTestCheckAttributes("statuscake_test.google", &test),
+                               ),
+                       },
+               },
+       })
+}
+
 func TestAccStatusCake_withUpdate(t *testing.T) {
        var test statuscake.Test
 
@@ -37,14 +56,14 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
                Providers:    testAccProviders,
                CheckDestroy: testAccTestCheckDestroy(&test),
                Steps: []resource.TestStep{
-                       resource.TestStep{
+                       {
                                Config: testAccTestConfig_basic,
                                Check: resource.ComposeTestCheckFunc(
                                        testAccTestCheckExists("statuscake_test.google", &test),
                                ),
                        },
 
-                       resource.TestStep{
+                       {
                                Config: testAccTestConfig_update,
                                Check: resource.ComposeTestCheckFunc(
                                        testAccTestCheckExists("statuscake_test.google", &test),
@@ -163,3 +182,16 @@ resource "statuscake_test" "google" {
        paused = true
 }
 `
+
+const testAccTestConfig_tcp = `
+resource "statuscake_test" "google" {
+       website_name = "google.com"
+       website_url = "www.google.com"
+       test_type = "TCP"
+       check_rate = 300
+       timeout = 10
+       contact_id = 12345
+       confirmations = 1
+       port = 80
+}
+`