Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug: artifact_registry_repository update always failing #4482

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mmv1/products/artifactregistry/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ apis_required:
name: Artifact Registry API
url: https://console.cloud.google.com/apis/library/artifactregistry.googleapis.com/
async: !ruby/object:Api::OpAsync
actions: ['create', 'delete']
operation: !ruby/object:Api::OpAsync::Operation
path: 'name'
base_url: '{{op_id}}'
Expand All @@ -47,6 +48,8 @@ objects:
base_url: projects/{{project}}/locations/{{location}}/repositories
create_url: projects/{{project}}/locations/{{location}}/repositories?repository_id={{repository_id}}
self_link: projects/{{project}}/locations/{{location}}/repositories/{{repository_id}}
update_verb: :PATCH
update_mask: true
min_version: beta
description: A repository for storing artifacts
references: !ruby/object:Api::Resource::ReferenceLinks
Expand Down
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 -%>