diff options
author | stack72 <public@paulstack.co.uk> | 2015-10-01 23:09:13 +0100 |
---|---|---|
committer | stack72 <public@paulstack.co.uk> | 2015-11-27 15:03:13 +0000 |
commit | b8f05dfc572fcdd53e58e0a1e3851ccc4db8f17e (patch) | |
tree | 4f16c88b4d948611bd150b6f7152e2a409598a61 /resource_statuscaketest_test.go | |
parent | 478e133852c1c49f98c0388920142dc507479487 (diff) | |
download | terraform-provider-statuscake-b8f05dfc572fcdd53e58e0a1e3851ccc4db8f17e.tar.gz terraform-provider-statuscake-b8f05dfc572fcdd53e58e0a1e3851ccc4db8f17e.tar.zst terraform-provider-statuscake-b8f05dfc572fcdd53e58e0a1e3851ccc4db8f17e.zip |
Using the latest version of the statuscake client
Diffstat (limited to 'resource_statuscaketest_test.go')
-rw-r--r-- | resource_statuscaketest_test.go | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/resource_statuscaketest_test.go b/resource_statuscaketest_test.go new file mode 100644 index 0000000..8bbd4b5 --- /dev/null +++ b/resource_statuscaketest_test.go | |||
@@ -0,0 +1,76 @@ | |||
1 | package statuscake | ||
2 | |||
3 | import ( | ||
4 | "fmt" | ||
5 | "testing" | ||
6 | |||
7 | "github.com/DreamItGetIT/statuscake" | ||
8 | "github.com/hashicorp/terraform/helper/resource" | ||
9 | "github.com/hashicorp/terraform/terraform" | ||
10 | ) | ||
11 | |||
12 | func TestAccStatusCake_basic(t *testing.T) { | ||
13 | var test statuscake.Test | ||
14 | |||
15 | resource.Test(t, resource.TestCase{ | ||
16 | PreCheck: func() { testAccPreCheck(t) }, | ||
17 | Providers: testAccProviders, | ||
18 | CheckDestroy: testAccTestCheckDestroy(&test), | ||
19 | Steps: []resource.TestStep{ | ||
20 | resource.TestStep{ | ||
21 | Config: testAccTestConfig_basic, | ||
22 | Check: resource.ComposeTestCheckFunc( | ||
23 | testAccTestCheckExists("statuscake_test.google", &test), | ||
24 | ), | ||
25 | }, | ||
26 | }, | ||
27 | }) | ||
28 | } | ||
29 | |||
30 | func testAccTestCheckExists(rn string, project *statuscake.Test) resource.TestCheckFunc { | ||
31 | return func(s *terraform.State) error { | ||
32 | rs, ok := s.RootModule().Resources[rn] | ||
33 | if !ok { | ||
34 | return fmt.Errorf("resource not found: %s", rn) | ||
35 | } | ||
36 | |||
37 | if rs.Primary.ID == "" { | ||
38 | return fmt.Errorf("TestID not set") | ||
39 | } | ||
40 | |||
41 | // client := testAccProvider.Meta().(*statuscake.Client) | ||
42 | // gotProject, err := client.GetProject(rs.Primary.ID) | ||
43 | // if err != nil { | ||
44 | // return fmt.Errorf("error getting project: %s", err) | ||
45 | // } | ||
46 | // | ||
47 | // *project = *gotProject | ||
48 | |||
49 | return nil | ||
50 | } | ||
51 | } | ||
52 | |||
53 | func testAccTestCheckDestroy(project *statuscake.Test) resource.TestCheckFunc { | ||
54 | // return func(s *terraform.State) error { | ||
55 | // client := testAccProvider.Meta().(*statuscake.Client) | ||
56 | // // _, err := client.Tests().All() | ||
57 | // // if err == nil { | ||
58 | // // return fmt.Errorf("test still exists") | ||
59 | // // } | ||
60 | // // if _, ok := err.(*statuscake.NotFoundError); !ok { | ||
61 | // // return fmt.Errorf("got something other than NotFoundError (%v) when getting test", err) | ||
62 | // // } | ||
63 | // | ||
64 | // return nil | ||
65 | // } | ||
66 | return nil | ||
67 | } | ||
68 | |||
69 | const testAccTestConfig_basic = ` | ||
70 | resource "statuscake_test" "google" { | ||
71 | website_name = "google.com" | ||
72 | website_url = "www.google.com" | ||
73 | test_type = "HTTP" | ||
74 | check_rate = 300 | ||
75 | } | ||
76 | ` | ||