Skip to content

Commit

Permalink
Fix labels related tests (#11873) (#19700)
Browse files Browse the repository at this point in the history
[upstream:4da617806521ef46b7b66cf84bf2f79687015345]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician committed Sep 30, 2024
1 parent efda35b commit c4e8c3e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/11873.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
13 changes: 8 additions & 5 deletions google/services/cloudrun/resource_cloud_run_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ func TestAccCloudRunService_withProviderDefaultLabels(t *testing.T) {

resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.%", "1"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.generated-by", "magic-modules"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "6"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "7"),
),
},
{
Expand All @@ -449,7 +449,7 @@ func TestAccCloudRunService_withProviderDefaultLabels(t *testing.T) {

resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.%", "1"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.generated-by", "magic-modules-update"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "6"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "7"),
),
},
{
Expand Down Expand Up @@ -508,7 +508,7 @@ func TestAccCloudRunService_withProviderDefaultLabels(t *testing.T) {
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_labels.%", "1"),

resource.TestCheckNoResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.%"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "5"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "6"),
),
},
{
Expand Down Expand Up @@ -547,8 +547,11 @@ func TestAccCloudRunServiceMigration_withLabels(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.labels.%", "2"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_labels.%", "3"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.%", "1"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "6"),
// A new system annotation is added by the API around 08/28/2024,
// and the current service annotation filter doesn't work for this new annotation during the migration,
// so it is treated as the user defined annotation.
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.annotations.%", "2"),
resource.TestCheckResourceAttr("google_cloud_run_service.default", "metadata.0.effective_annotations.%", "7"),
),
},
},
Expand Down
19 changes: 11 additions & 8 deletions google/services/container/resource_container_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10470,11 +10470,12 @@ func TestAccContainerCluster_withProviderDefaultLabels(t *testing.T) {
resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "1"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.created-by", "terraform"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"),
// goog-terraform-provisioned: true is added
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "3"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "default_value1"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "3"),
),
},
{
Expand All @@ -10490,11 +10491,12 @@ func TestAccContainerCluster_withProviderDefaultLabels(t *testing.T) {
resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.created-by", "terraform"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "value1"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"),
// goog-terraform-provisioned: true is added
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "3"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "value1"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "3"),
),
},
{
Expand All @@ -10508,11 +10510,12 @@ func TestAccContainerCluster_withProviderDefaultLabels(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "0"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "2"),
// goog-terraform-provisioned: true is added
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "3"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.default_key1", "default_value1"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.created-by", "terraform"),

resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "2"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "3"),
),
},
{
Expand All @@ -10525,8 +10528,8 @@ func TestAccContainerCluster_withProviderDefaultLabels(t *testing.T) {
Config: testAccContainerCluster_basic(clusterName, networkName, subnetworkName),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr("google_container_cluster.primary", "resource_labels.%", "0"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "0"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "0"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "terraform_labels.%", "1"),
resource.TestCheckResourceAttr("google_container_cluster.primary", "effective_labels.%", "1"),
),
},
{
Expand Down
3 changes: 2 additions & 1 deletion google/services/dataflow/resource_dataflow_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,8 @@ func TestAccDataflowJob_withProviderDefaultLabels(t *testing.T) {
Config: testAccDataflowJob_zone(bucket, job, zone),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckNoResourceAttr("google_dataflow_job.big_data", "labels.%"),
resource.TestCheckResourceAttr("google_dataflow_job.big_data", "effective_labels.%", "3"),
// goog-terraform-provisioned: true is added
resource.TestCheckResourceAttr("google_dataflow_job.big_data", "effective_labels.%", "4"),
),
},
{
Expand Down

0 comments on commit c4e8c3e

Please sign in to comment.