Skip to content

Commit

Permalink
Add test for defaultUrlRedirect
Browse files Browse the repository at this point in the history
  • Loading branch information
ctavan committed Apr 22, 2020
1 parent a00cd6c commit 62d1d71
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,28 @@ func TestAccComputeRegionUrlMap_ilbRouteUpdate(t *testing.T) {
})
}

func TestAccComputeRegionUrlMap_defaultUrlRedirect(t *testing.T) {
t.Parallel()

randomSuffix := randString(t, 10)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeUrlMapDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionUrlMap_defaultUrlRedirectConfig(randomSuffix),
},
{
ResourceName: "google_compute_region_url_map.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeRegionUrlMap_basic1(randomSuffix string) string {
return fmt.Sprintf(`
resource "google_compute_region_backend_service" "foobar" {
Expand Down Expand Up @@ -822,4 +844,15 @@ resource "google_compute_region_health_check" "default" {
}
`, randomSuffix, randomSuffix, randomSuffix, randomSuffix)
}

func testAccComputeRegionUrlMap_defaultUrlRedirectConfig(randomSuffix string) string {
return fmt.Sprintf(`
resource "google_compute_region_url_map" "foobar" {
name = "urlmap-test-%s"
default_url_redirect {
https_redirect = true
}
}
`, randomSuffix)
}
<% end -%>
33 changes: 33 additions & 0 deletions third_party/terraform/tests/resource_compute_url_map_test.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,28 @@ func TestAccComputeUrlMap_trafficDirectorRemoveRouteRule(t *testing.T) {
})
}

func TestAccComputeUrlMap_defaultUrlRedirect(t *testing.T) {
t.Parallel()

randomSuffix := randString(t, 10)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeUrlMapDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeUrlMap_defaultUrlRedirectConfig(randomSuffix),
},
{
ResourceName: "google_compute_url_map.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccComputeUrlMap_basic1(bsName, hcName, umName string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "foobar" {
Expand Down Expand Up @@ -941,3 +963,14 @@ resource "google_compute_health_check" "default" {
}
`, umName, bsName, bsName, hcName)
}

func testAccComputeUrlMap_defaultUrlRedirectConfig(randomSuffix string) string {
return fmt.Sprintf(`
resource "google_compute_url_map" "foobar" {
name = "urlmap-test-%s"
default_url_redirect {
https_redirect = true
}
}
`, randomSuffix)
}

0 comments on commit 62d1d71

Please sign in to comment.