package statuscake
import (
+ "fmt"
"os"
+ "strconv"
"testing"
"github.com/hashicorp/terraform/helper/schema"
var testAccProviders map[string]terraform.ResourceProvider
var testAccProvider *schema.Provider
+var testContactGroupId int
func init() {
testAccProvider = Provider().(*schema.Provider)
testAccProviders = map[string]terraform.ResourceProvider{
"statuscake": testAccProvider,
}
+
+ if v := os.Getenv("STATUSCAKE_TEST_CONTACT_GROUP_ID"); v == "" {
+ fmt.Println("STATUSCAKE_TEST_CONTACT_GROUP_ID must be set for acceptance tests")
+ os.Exit(1)
+ } else {
+ id, err := strconv.Atoi(v)
+ if err != nil {
+ fmt.Println("STATUSCAKE_TEST_CONTACT_GROUP_ID must be a valid int")
+ os.Exit(1)
+ }
+ testContactGroupId = id
+ }
}
func TestProvider(t *testing.T) {
CheckDestroy: testAccTestCheckDestroy(&test),
Steps: []resource.TestStep{
{
- Config: testAccTestConfig_basic,
+ Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId),
Check: resource.ComposeTestCheckFunc(
testAccTestCheckExists("statuscake_test.google", &test),
testAccTestCheckAttributes("statuscake_test.google", &test),
CheckDestroy: testAccTestCheckDestroy(&test),
Steps: []resource.TestStep{
{
- Config: testAccTestConfig_tcp,
+ Config: fmt.Sprintf(testAccTestConfig_tcp, testContactGroupId),
Check: resource.ComposeTestCheckFunc(
testAccTestCheckExists("statuscake_test.google", &test),
testAccTestCheckAttributes("statuscake_test.google", &test),
CheckDestroy: testAccTestCheckDestroy(&test),
Steps: []resource.TestStep{
{
- Config: testAccTestConfig_basic,
+ Config: fmt.Sprintf(testAccTestConfig_basic, testContactGroupId),
Check: resource.ComposeTestCheckFunc(
testAccTestCheckExists("statuscake_test.google", &test),
),
test_type = "HTTP"
check_rate = 300
timeout = 10
- contact_id = 43402
+ contact_id = %d
confirmations = 1
trigger_rate = 10
}
test_type = "TCP"
check_rate = 300
timeout = 10
- contact_id = 43402
+ contact_id = %d
confirmations = 1
port = 80
}