From 169be9d553484385fbd06c6609feb9f363b27ac0 Mon Sep 17 00:00:00 2001 From: Obada Alabbadi Date: Fri, 13 Dec 2024 14:06:37 +0000 Subject: [PATCH] Move BQ external AWS dataset test to resource_bigquery_dataset_test --- mmv1/products/bigquery/Dataset.yaml | 5 --- ...ataset_external_reference_aws_test.tf.tmpl | 11 ----- .../resource_bigquery_dataset_test.go.tmpl | 43 ++++++++++++++++++- 3 files changed, 42 insertions(+), 17 deletions(-) delete mode 100644 mmv1/templates/terraform/examples/bigquery_dataset_external_reference_aws_test.tf.tmpl diff --git a/mmv1/products/bigquery/Dataset.yaml b/mmv1/products/bigquery/Dataset.yaml index 0d1161786cc6..2e9b8ca046e7 100644 --- a/mmv1/products/bigquery/Dataset.yaml +++ b/mmv1/products/bigquery/Dataset.yaml @@ -85,11 +85,6 @@ examples: dataset_id: 'example_dataset' account_name: 'bqowner' exclude_docs: true - - name: 'bigquery_dataset_external_reference_aws_test' - primary_resource_id: 'dataset' - vars: - dataset_id: 'example_dataset' - exclude_docs: true - name: 'bigquery_dataset_external_reference_aws' primary_resource_id: 'dataset' vars: diff --git a/mmv1/templates/terraform/examples/bigquery_dataset_external_reference_aws_test.tf.tmpl b/mmv1/templates/terraform/examples/bigquery_dataset_external_reference_aws_test.tf.tmpl deleted file mode 100644 index 909aac1f6f9e..000000000000 --- a/mmv1/templates/terraform/examples/bigquery_dataset_external_reference_aws_test.tf.tmpl +++ /dev/null @@ -1,11 +0,0 @@ -resource "google_bigquery_dataset" "{{$.PrimaryResourceId}}" { - dataset_id = "{{index $.Vars "dataset_id"}}" - friendly_name = "test" - description = "This is a test description" - location = "aws-us-east-1" - - external_dataset_reference { - external_source = "aws-glue://arn:aws:glue:us-east-1:772042918353:database/db_other_formats_external" - connection = "projects/bigquerytestdefault/locations/aws-us-east-1/connections/external_test-connection" - } -} diff --git a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go.tmpl b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go.tmpl index 7cac6a1716fd..abf9db003795 100644 --- a/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go.tmpl +++ b/mmv1/third_party/terraform/services/bigquery/resource_bigquery_dataset_test.go.tmpl @@ -463,6 +463,31 @@ func TestAccBigQueryDataset_bigqueryDatasetResourceTags_update(t *testing.T) { }) } +func TestAccBigQueryDataset_bigqueryDatasetExternalReferenceAws(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "random_suffix": acctest.RandString(t, 10), + } + + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckBigQueryDatasetDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBigQueryDataset_bigqueryDatasetExternalReferenceAws(context), + }, + { + ResourceName: "google_bigquery_dataset.dataset", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"labels", "terraform_labels"}, + }, + }, + }) +} + {{- if ne $.TargetVersionName "ga" }} func TestAccBigQueryDataset_externalCatalogDatasetOptions_update(t *testing.T) { t.Parallel() @@ -727,7 +752,7 @@ resource "google_bigquery_dataset" "access_test" { access { role = "READER" - user_by_email = "Sam@example.com" + user_by_email = "hashicorp.com" condition { title = "test-condition" description = "Request after midnight of 2019-12-31" @@ -977,3 +1002,19 @@ resource "google_bigquery_dataset" "dataset" { } `, context) } + +func testAccBigQueryDataset_bigqueryDatasetExternalReferenceAws(context map[string]interface{}) string { + return acctest.Nprintf(` +resource "google_bigquery_dataset" "dataset" { + dataset_id = "dataset%{random_suffix}" + friendly_name = "test" + description = "This is a test description" + location = "aws-us-east-1" + + external_dataset_reference { + external_source = "aws-glue://arn:aws:glue:us-east-1:772042918353:database/db_other_formats_external" + connection = "projects/bigquerytestdefault/locations/aws-us-east-1/connections/external_test-connection" + } +} +`, context) +}