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,
},
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))
d.Set("timeout", testResp.Timeout)
d.Set("contact_id", testResp.ContactID)
d.Set("confirmations", testResp.Confirmation)
+ d.Set("port", testResp.Port)
return nil
}
if v, ok := d.GetOk("confirmations"); ok {
test.Confirmation = v.(int)
}
+ if v, ok := d.GetOk("port"); ok {
+ test.Port = v.(int)
+ }
return test
}
Providers: testAccProviders,
CheckDestroy: testAccTestCheckDestroy(&test),
Steps: []resource.TestStep{
- resource.TestStep{
+ {
Config: testAccTestConfig_basic,
Check: resource.ComposeTestCheckFunc(
testAccTestCheckExists("statuscake_test.google", &test),
})
}
+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
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),
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
+}
+`