Skip to content

Commit

Permalink
modify fields, added update test
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn committed Dec 4, 2019
1 parent 1caa6f3 commit 781763f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions products/sourcerepo/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ objects:
values:
- :PROTOBUF
- :JSON
required: true
- !ruby/object:Api::Type::String
name: 'serviceAccountEmail'
description: |
Expand Down
2 changes: 2 additions & 0 deletions products/sourcerepo/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
description: |
Resource name of the repository, of the form `{{repo}}`.
The repo name may contain slashes. eg, `name/with/slash`
pubsubConfigs.serviceAccountEmail: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
custom_code: !ruby/object:Provider::Terraform::CustomCode
update_encoder: templates/terraform/update_encoder/source_repo_repository.erb
post_create: templates/terraform/post_create/source_repo_repository_update.go.erb
Expand Down
51 changes: 51 additions & 0 deletions third_party/terraform/tests/resource_sourcerepo_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,61 @@ func TestAccSourceRepoRepository_basic(t *testing.T) {
})
}

func TestAccSourceRepoRepository_update(t *testing.T) {
t.Parallel()

repositoryName := fmt.Sprintf("source-repo-repository-test-%s", acctest.RandString(10))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckSourceRepoRepositoryDestroy,
Steps: []resource.TestStep{
{
Config: testAccSourceRepoRepository_basic(repositoryName),
},
{
ResourceName: "google_sourcerepo_repository.acceptance",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccSourceRepoRepository_extended(repositoryName),
},
{
ResourceName: "google_sourcerepo_repository.acceptance",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func testAccSourceRepoRepository_basic(repositoryName string) string {
return fmt.Sprintf(`
resource "google_sourcerepo_repository" "acceptance" {
name = "%s"
}
`, repositoryName)
}

func testAccSourceRepoRepository_extended(repositoryName string) string {
return fmt.Sprintf(`
resource "google_service_account" "test-account" {
account_id = "service-account-update"
display_name = "Test Service Account"
}
resource "google_pubsub_topic" "topic" {
name = "topic-update"
}
resource "google_sourcerepo_repository" "acceptance" {
name = "%s"
pubsub_configs {
topic = google_pubsub_topic.topic.id
message_format = "JSON"
service_account_email = google_service_account.test-account.email
}
}
`, repositoryName)
}

0 comments on commit 781763f

Please sign in to comment.