Skip to content

Commit

Permalink
add available_secrets to unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
cgroschupp committed Nov 26, 2021
1 parent 434a7d2 commit 9fb0628
Showing 1 changed file with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ func TestAccCloudBuildTrigger_basic(t *testing.T) {
})
}

func TestAccCloudBuildTrigger_available_secrets_config(t *testing.T) {
t.Parallel()
name := fmt.Sprintf("tf-test-%d", randInt(t))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckCloudBuildTriggerDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccCloudBuildTrigger_available_secrets_config(name),
},
{
ResourceName: "google_cloudbuild_trigger.build_trigger",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccCloudBuildTrigger_available_secrets_config_update(name),
},
{
ResourceName: "google_cloudbuild_trigger.build_trigger",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccCloudBuildTrigger_pubsub_config(t *testing.T) {
t.Parallel()
name := fmt.Sprintf("tf-test-%d", randInt(t))
Expand Down Expand Up @@ -339,6 +368,56 @@ resource "google_cloudbuild_trigger" "build_trigger" {
`, name)
}

func testAccCloudBuildTrigger_available_secrets_config(name string) string {
return fmt.Sprintf(`
resource "google_cloudbuild_trigger" "build_trigger" {
name = "%s"
description = "acceptance test build trigger"
trigger_template {
branch_name = "master"
repo_name = "some-repo"
}
build {
tags = ["team-a", "service-b"]
timeout = "1800s"
step {
name = "gcr.io/cloud-builders/gsutil"
args = ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
timeout = "300s"
}
available_secrets {
secret_manager {
env = "MY_SECRET"
version_name = "projects/myProject/secrets/mySecret/versions/latest"
}
}
}
}
`, name)
}

func testAccCloudBuildTrigger_available_secrets_config_update(name string) string {
return fmt.Sprintf(`
resource "google_cloudbuild_trigger" "build_trigger" {
name = "%s"
description = "acceptance test build trigger updated"
trigger_template {
branch_name = "master"
repo_name = "some-repo"
}
build {
tags = ["team-a", "service-b"]
timeout = "1800s"
step {
name = "gcr.io/cloud-builders/gsutil"
args = ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"]
timeout = "300s"
}
}
}
`, name)
}

func testAccCloudBuildTrigger_pubsub_config(name string) string {
return fmt.Sprintf(`
resource "google_pubsub_topic" "build-trigger" {
Expand Down

0 comments on commit 9fb0628

Please sign in to comment.