Add support for StatusCake trigger rate

This commit is contained in:
Rui Gonçalves 2017-04-04 16:58:11 +01:00 committed by stack72
parent a80c8bb4de
commit 0e2a3354be
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
2 changed files with 16 additions and 0 deletions

View File

@ -70,6 +70,12 @@ func resourceStatusCakeTest() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
},
"trigger_rate": {
Type: schema.TypeInt,
Optional: true,
Default: 5,
},
},
}
}
@ -87,6 +93,7 @@ func CreateTest(d *schema.ResourceData, meta interface{}) error {
ContactID: d.Get("contact_id").(int),
Confirmation: d.Get("confirmations").(int),
Port: d.Get("port").(int),
TriggerRate: d.Get("trigger_rate").(int),
}
log.Printf("[DEBUG] Creating new StatusCake Test: %s", d.Get("website_name").(string))
@ -151,6 +158,7 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error {
d.Set("contact_id", testResp.ContactID)
d.Set("confirmations", testResp.Confirmation)
d.Set("port", testResp.Port)
d.Set("trigger_rate", testResp.TriggerRate)
return nil
}
@ -193,6 +201,9 @@ func getStatusCakeTestInput(d *schema.ResourceData) *statuscake.Test {
if v, ok := d.GetOk("port"); ok {
test.Port = v.(int)
}
if v, ok := d.GetOk("trigger_rate"); ok {
test.TriggerRate = v.(int)
}
defaultStatusCodes := "204, 205, 206, 303, 400, 401, 403, 404, 405, 406, " +
"408, 410, 413, 444, 429, 494, 495, 496, 499, 500, 501, 502, 503, " +

View File

@ -73,6 +73,7 @@ func TestAccStatusCake_withUpdate(t *testing.T) {
resource.TestCheckResourceAttr("statuscake_test.google", "timeout", "40"),
resource.TestCheckResourceAttr("statuscake_test.google", "contact_id", "0"),
resource.TestCheckResourceAttr("statuscake_test.google", "confirmations", "0"),
resource.TestCheckResourceAttr("statuscake_test.google", "trigger_rate", "20"),
),
},
},
@ -139,6 +140,8 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC
err = check(key, value, strconv.Itoa(test.ContactID))
case "confirmations":
err = check(key, value, strconv.Itoa(test.Confirmation))
case "trigger_rate":
err = check(key, value, strconv.Itoa(test.TriggerRate))
}
if err != nil {
@ -170,6 +173,7 @@ resource "statuscake_test" "google" {
timeout = 10
contact_id = 43402
confirmations = 1
trigger_rate = 10
}
`
@ -180,6 +184,7 @@ resource "statuscake_test" "google" {
test_type = "HTTP"
check_rate = 500
paused = true
trigger_rate = 20
}
`