-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug: artifact_registry_repository update always failing (#4482)
This fixes a bug where trying to update an artifact_registry_repository always failed due to the fact that the resource's Update logic was hitting the wrong API endpoint.
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
mmv1/third_party/terraform/tests/resource_artifact_registry_repository_test.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<% autogen_exception -%> | ||
package google | ||
<% unless version == 'ga' -%> | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccArtifactRegistryRepository_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
repositoryID := fmt.Sprintf("tf-test-%d", randInt(t)) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProvidersOiCS, | ||
CheckDestroy: testAccCheckArtifactRegistryRepositoryDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccArtifactRegistryRepository_update(repositoryID), | ||
}, | ||
{ | ||
ResourceName: "google_artifact_registry_repository.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccArtifactRegistryRepository_update2(repositoryID), | ||
}, | ||
{ | ||
ResourceName: "google_artifact_registry_repository.test", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccArtifactRegistryRepository_update(repositoryID string) string { | ||
return fmt.Sprintf(` | ||
resource "google_artifact_registry_repository" "test" { | ||
provider = google-beta | ||
|
||
repository_id = "%s" | ||
location = "us-central1" | ||
description = "pre-update" | ||
format = "DOCKER" | ||
|
||
labels = { | ||
my_key = "my_val" | ||
other_key = "other_val" | ||
} | ||
} | ||
`, repositoryID) | ||
} | ||
|
||
func testAccArtifactRegistryRepository_update2(repositoryID string) string { | ||
return fmt.Sprintf(` | ||
resource "google_artifact_registry_repository" "test" { | ||
provider = google-beta | ||
|
||
repository_id = "%s" | ||
location = "us-central1" | ||
description = "post-update" | ||
format = "DOCKER" | ||
|
||
labels = { | ||
my_key = "my_val" | ||
other_key = "new_val" | ||
} | ||
} | ||
`, repositoryID) | ||
} | ||
<% end -%> |