File tree Expand file tree Collapse file tree 4 files changed +16
-7
lines changed
third_party/terraform/acctest Expand file tree Collapse file tree 4 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -1722,6 +1722,13 @@ func (r Resource) FirstTestConfig() TestConfig {
17221722 return TestConfig {}
17231723}
17241724
1725+ func (r Resource ) NeedsEnvVar () bool {
1726+ if r .ProductMetadata != nil && r .ProductMetadata .Name == "BiglakeIceberg" && (r .Name == "IcebergNamespace" || r .Name == "IcebergCatalog" ) {
1727+ return false
1728+ }
1729+ return true
1730+ }
1731+
17251732func (r Resource ) ExamplePrimaryResourceId () string {
17261733 examples := google .Reject (r .Examples , func (e * resource.Examples ) bool {
17271734 return e .ExcludeTest
Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ import (
2929 " github.com/hashicorp/terraform-plugin-testing/terraform"
3030
3131 " {{ $.ImportPath }}/acctest"
32+ {{- if $ .Res.NeedsEnvVar }}
3233 " {{ $.ImportPath }}/envvar"
34+ {{- end }}
3335 " {{ $.ImportPath }}/tpgresource"
3436 transport_tpg " {{ $.ImportPath }}/transport"
3537
4446 _ = time.Now
4547 _ = resource.TestMain
4648 _ = terraform.NewState
49+ {{- if $ .Res.NeedsEnvVar }}
4750 _ = envvar.TestEnvVar
51+ {{- end }}
4852 _ = tpgresource.SetLabels
4953 _ = transport_tpg.Config {}
5054 _ = googleapi.Error {}
Original file line number Diff line number Diff line change @@ -33,7 +33,9 @@ import (
3333{{- end }}
3434
3535 " {{ $.ImportPath }}/acctest"
36+ {{- if $ .Res.NeedsEnvVar }}
3637 " {{ $.ImportPath }}/envvar"
38+ {{- end }}
3739 " {{ $.ImportPath }}/tpgresource"
3840 transport_tpg " {{ $.ImportPath }}/transport"
3941)
Original file line number Diff line number Diff line change @@ -267,17 +267,13 @@ func TestValidateResourceMetadata(t *testing.T) {
267267 if r .ApiServiceName == "" {
268268 t .Errorf ("%s: `api_service_name` is required and not set" , r .Resource )
269269 }
270- // Allowlist google_biglake_iceberg_catalog as a pre-existing case. I believe
270+ ignoredResources := []string {"google_biglake_iceberg_catalog" , "google_biglake_iceberg_namespace" }
271+ // Allowlist google_biglake_iceberg_catalog and google_biglake_iceberg_namespace as a pre-existing case. I believe
271272 // that's a mistake which should be corrected at some point in the future.
272- if r .ApiVersion == "" && resourceName != "google_biglake_iceberg_catalog" {
273+ if r .ApiVersion == "" && ! slices . Contains ( ignoredResources , resourceName ) {
273274 t .Errorf ("%s: `api_version` is required and not set" , r .Resource )
274275 }
275276
276- // Allowlist google_biglake_iceberg_namespace as a pre-existing case. I believe
277- // that's a mistake which should be corrected at some point in the future.
278- if r .ApiVersion == "" && resourceName != "google_biglake_iceberg_namespace" {
279- t .Errorf ("%s: `api_version` is required and not set" , r .Resource )
280- }
281277 if r .ApiResourceTypeKind == "" {
282278 t .Errorf ("%s: `api_resource_type_kind` is required and not set" , r .Resource )
283279 }
You can’t perform that action at this time.
0 commit comments