Skip to content

Commit

Permalink
Change region field required to default_from_api (GoogleCloudPlatform…
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelJas authored May 17, 2024
1 parent 1c8b63f commit 2f6d3ce
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mmv1/products/compute/RegionSslPolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ parameters:
name: 'region'
resource: 'Region'
imports: 'name'
required: true
default_from_api: true
immutable: true
description: |
The region where the regional SSL policy resides.
custom_flatten: 'templates/terraform/custom_flatten/name_from_self_link.erb'
custom_expand: 'templates/terraform/custom_expand/resourceref_with_validation.go.erb'
properties:
- !ruby/object:Api::Type::Time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,36 @@ import (
<% end -%>
)

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

sslPolicyName := fmt.Sprintf("test-ssl-policy-%s", acctest.RandString(t, 10))

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeSslPolicyDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRegionSslRegionDefaultFromEnv(sslPolicyName),
},
{
ResourceName: "google_compute_region_ssl_policy.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRegionSslUpdateRegionDefaultFromEnv(sslPolicyName),
},
{
ResourceName: "google_compute_region_ssl_policy.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

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

Expand Down Expand Up @@ -229,3 +259,25 @@ resource "google_compute_region_ssl_policy" "update" {
}
`, resourceName)
}

func testAccComputeRegionSslRegionDefaultFromEnv(resourceName string) string {
return fmt.Sprintf(`
resource "google_compute_region_ssl_policy" "foobar" {
name = "%s"
description = "Generated by TF provider acceptance test"
min_tls_version = "TLS_1_0"
profile = "MODERN"
}
`, resourceName)
}

func testAccComputeRegionSslUpdateRegionDefaultFromEnv(resourceName string) string {
return fmt.Sprintf(`
resource "google_compute_region_ssl_policy" "foobar" {
name = "%s"
description = "Generated by TF provider acceptance test - updated"
min_tls_version = "TLS_1_0"
profile = "MODERN"
}
`, resourceName)
}

0 comments on commit 2f6d3ce

Please sign in to comment.