From ef20d8d74891bfcfbf17088c4cd9c39cd1e347dd Mon Sep 17 00:00:00 2001 From: Mat Schaffer Date: Thu, 1 Feb 2018 16:15:21 +0900 Subject: Don't attempt to set or verify values which aren't present in the details response The `TestCheckResourceAttr` tests can stay since they rely on the state from the previous apply. --- statuscake/resource_statuscaketest.go | 15 +++++---------- statuscake/resource_statuscaketest_test.go | 18 ------------------ 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/statuscake/resource_statuscaketest.go b/statuscake/resource_statuscaketest.go index b2b0c68..d7d3f36 100644 --- a/statuscake/resource_statuscaketest.go +++ b/statuscake/resource_statuscaketest.go @@ -314,24 +314,19 @@ func ReadTest(d *schema.ResourceData, meta interface{}) error { d.Set("port", testResp.Port) d.Set("trigger_rate", testResp.TriggerRate) d.Set("custom_header", testResp.CustomHeader) - d.Set("user_agent", testResp.UserAgent) d.Set("status", testResp.Status) d.Set("uptime", testResp.Uptime) if err := d.Set("node_locations", considerEmptyStringAsEmptyArray(testResp.NodeLocations)); err != nil { return fmt.Errorf("[WARN] Error setting node locations: %s", err) } - d.Set("ping_url", testResp.PingURL) - d.Set("basic_user", testResp.BasicUser) - d.Set("basic_pass", testResp.BasicPass) - d.Set("public", testResp.Public) d.Set("logo_image", testResp.LogoImage) - d.Set("branding", testResp.Branding) - d.Set("website_host", testResp.WebsiteHost) - d.Set("virus", testResp.Virus) + // Even after WebsiteHost is set, the API returns "" + // API docs aren't clear on usage will only override state if we get a non-empty value back + if testResp.WebsiteHost != "" { + d.Set("website_host", testResp.WebsiteHost) + } d.Set("find_string", testResp.FindString) d.Set("do_not_find", testResp.DoNotFind) - d.Set("real_browser", testResp.RealBrowser) - d.Set("test_tags", testResp.TestTags) d.Set("status_codes", testResp.StatusCodes) d.Set("use_jar", testResp.UseJar) d.Set("post_raw", testResp.PostRaw) diff --git a/statuscake/resource_statuscaketest_test.go b/statuscake/resource_statuscaketest_test.go index 555cff1..da3a349 100644 --- a/statuscake/resource_statuscaketest_test.go +++ b/statuscake/resource_statuscaketest_test.go @@ -166,8 +166,6 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC err = check(key, value, strconv.Itoa(test.TriggerRate)) case "custom_header": err = check(key, value, test.CustomHeader) - case "user_agent": - err = check(key, value, test.UserAgent) case "node_locations": for _, tv := range test.NodeLocations { err = check(key, value, tv) @@ -175,30 +173,14 @@ func testAccTestCheckAttributes(rn string, test *statuscake.Test) resource.TestC return err } } - case "ping_url": - err = check(key, value, test.PingURL) - case "basic_user": - err = check(key, value, test.BasicUser) - case "basic_pass": - err = check(key, value, test.BasicPass) case "public": err = check(key, value, strconv.Itoa(test.Public)) case "logo_image": err = check(key, value, test.LogoImage) - case "branding": - err = check(key, value, strconv.Itoa(test.Branding)) - case "website_host": - err = check(key, value, test.WebsiteHost) - case "virus": - err = check(key, value, strconv.Itoa(test.Virus)) case "find_string": err = check(key, value, test.FindString) case "do_not_find": err = check(key, value, strconv.FormatBool(test.DoNotFind)) - case "real_browser": - err = check(key, value, strconv.Itoa(test.RealBrowser)) - case "test_tags": - err = check(key, value, test.TestTags) case "status_codes": err = check(key, value, test.StatusCodes) case "use_jar": -- cgit v1.2.3