Skip to content

Commit

Permalink
provider/google: fix url map test and update logic (#12317)
Browse files Browse the repository at this point in the history
  • Loading branch information
danawillow authored and stack72 committed Mar 1, 2017
1 parent 5efc86e commit 75eb920
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions builtin/providers/google/resource_compute_url_map.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ func resourceComputeUrlMapUpdate(d *schema.ResourceData, meta interface{}) error
urlMap.PathMatchers = newPathMatchers
}

if d.HasChange("tests") {
_oldTests, _newTests := d.GetChange("path_matcher")
if d.HasChange("test") {
_oldTests, _newTests := d.GetChange("test")
_oldTestsMap := make(map[string]interface{})
_newTestsMap := make(map[string]interface{})

Expand Down
26 changes: 18 additions & 8 deletions builtin/providers/google/resource_compute_url_map_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import (
)

func TestAccComputeUrlMap_basic(t *testing.T) {
bsName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
hcName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
umName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeUrlMapDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeUrlMap_basic1,
Config: testAccComputeUrlMap_basic1(bsName, hcName, umName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeUrlMapExists(
"google_compute_url_map.foobar"),
Expand All @@ -27,21 +30,24 @@ func TestAccComputeUrlMap_basic(t *testing.T) {
}

func TestAccComputeUrlMap_update_path_matcher(t *testing.T) {
bsName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
hcName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
umName := fmt.Sprintf("urlmap-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeUrlMapDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccComputeUrlMap_basic1,
Config: testAccComputeUrlMap_basic1(bsName, hcName, umName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeUrlMapExists(
"google_compute_url_map.foobar"),
),
},

resource.TestStep{
Config: testAccComputeUrlMap_basic2,
Config: testAccComputeUrlMap_basic2(bsName, hcName, umName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeUrlMapExists(
"google_compute_url_map.foobar"),
Expand Down Expand Up @@ -120,7 +126,8 @@ func testAccCheckComputeUrlMapExists(n string) resource.TestCheckFunc {
}
}

var testAccComputeUrlMap_basic1 = fmt.Sprintf(`
func testAccComputeUrlMap_basic1(bsName, hcName, umName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "urlmap-test-%s"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
Expand Down Expand Up @@ -157,9 +164,11 @@ resource "google_compute_url_map" "foobar" {
service = "${google_compute_backend_service.foobar.self_link}"
}
}
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
`, bsName, hcName, umName)
}

var testAccComputeUrlMap_basic2 = fmt.Sprintf(`
func testAccComputeUrlMap_basic2(bsName, hcName, umName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
name = "urlmap-test-%s"
health_checks = ["${google_compute_http_health_check.zero.self_link}"]
Expand Down Expand Up @@ -192,11 +201,12 @@ resource "google_compute_url_map" "foobar" {
test {
host = "mysite.com"
path = "/*"
path = "/test"
service = "${google_compute_backend_service.foobar.self_link}"
}
}
`, acctest.RandString(10), acctest.RandString(10), acctest.RandString(10))
`, bsName, hcName, umName)
}

var testAccComputeUrlMap_advanced1 = fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
Expand Down

0 comments on commit 75eb920

Please sign in to comment.