|
| 1 | +package google |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 7 | +) |
| 8 | + |
| 9 | +func TestAccDataSourceGoogleArtifactRegistryRepositoryConfig(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + |
| 12 | + context := map[string]interface{}{ |
| 13 | + "random_suffix": randString(t, 10), |
| 14 | + } |
| 15 | + funcDataName := "data.google_artifact_registry_repository.my-repo" |
| 16 | + |
| 17 | + vcrTest(t, resource.TestCase{ |
| 18 | + PreCheck: func() { testAccPreCheck(t) }, |
| 19 | + Providers: testAccProviders, |
| 20 | + CheckDestroy: testAccCheckArtifactRegistryRepositoryDestroyProducer(t), |
| 21 | + Steps: []resource.TestStep{ |
| 22 | + { |
| 23 | + Config: testAccDataSourceGoogleArtifactRegistryRepositoryConfig(context), |
| 24 | + Check: resource.ComposeTestCheckFunc( |
| 25 | + checkDataSourceStateMatchesResourceState(funcDataName, |
| 26 | + "google_artifact_registry_repository.my-repo"), |
| 27 | + ), |
| 28 | + }, |
| 29 | + }, |
| 30 | + }) |
| 31 | +} |
| 32 | + |
| 33 | +func testAccDataSourceGoogleArtifactRegistryRepositoryConfig(context map[string]interface{}) string { |
| 34 | + return Nprintf(` |
| 35 | +resource "google_artifact_registry_repository" "my-repo" { |
| 36 | + location = "us-central1" |
| 37 | + repository_id = "tf-test-my-repository%{random_suffix}" |
| 38 | + description = "example docker repository%{random_suffix}" |
| 39 | + format = "DOCKER" |
| 40 | +} |
| 41 | +
|
| 42 | +data "google_artifact_registry_repository" "my-repo" { |
| 43 | + location = "us-central1" |
| 44 | + repository_id = google_artifact_registry_repository.my-repo.repository_id |
| 45 | +} |
| 46 | +`, context) |
| 47 | +} |
0 commit comments