Skip to content

Commit

Permalink
Fix the tests for datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
zli82016 committed Sep 14, 2023
1 parent c86a857 commit 2fb2868
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mmv1/products/cloudidentity/Group.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ properties:
output: true
description: |
The time when the Group was last updated.
- !ruby/object:Api::Type::KeyValueLabels
- !ruby/object:Api::Type::KeyValuePairs
name: 'labels'
required: true
description: |
Expand Down
6 changes: 6 additions & 0 deletions mmv1/third_party/terraform/acctest/test_utils.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ func CheckDataSourceStateMatchesResourceStateWithIgnores(dataSourceName, resourc
if _, ok := ignoreFields[k]; ok {
continue
}
if _, ok := ignoreFields["labels.%"]; ok && strings.HasPrefix(k, "labels.") {
continue
}
if _, ok := ignoreFields["terraform_labels.%"]; ok && strings.HasPrefix(k, "terraform_labels.") {
continue
}
if k == "%" {
continue
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ func TestAccDataSourceGoogleArtifactRegistryRepositoryConfig(t *testing.T) {
{
Config: testAccDataSourceGoogleArtifactRegistryRepositoryConfig(context),
Check: resource.ComposeTestCheckFunc(
acctest.CheckDataSourceStateMatchesResourceState(funcDataName,
"google_artifact_registry_repository.my-repo"),
acctest.CheckDataSourceStateMatchesResourceStateWithIgnores(funcDataName,
"google_artifact_registry_repository.my-repo", map[string]struct{}{"labels.%": {}, "terraform_labels.%": {}}),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ func TestAccDataSourceGoogleCloudFunctions2Function_basic(t *testing.T) {
{
Config: testAccDataSourceGoogleCloudFunctions2FunctionConfig(functionName,
bucketName, zipFilePath),
// As the value of "labels" and "terraform_lables" in the state is dpendent on the configuration,
// and these fields are not set in the configuration of the data source, so these fields are empty in the state of the data source.
Check: resource.ComposeTestCheckFunc(
acctest.CheckDataSourceStateMatchesResourceStateWithIgnores(funcDataNameHttp,
"google_cloudfunctions2_function.function_http_v2", map[string]struct{}{"build_config.0.source.0.storage_source.0.bucket": {}, "build_config.0.source.0.storage_source.0.object": {}}),
"google_cloudfunctions2_function.function_http_v2", map[string]struct{}{"build_config.0.source.0.storage_source.0.bucket": {}, "build_config.0.source.0.storage_source.0.object": {}, "labels.%": {}, "terraform_labels.%": {}}),
),
},
},
Expand Down

0 comments on commit 2fb2868

Please sign in to comment.