|
| 1 | +// Copyright (c) HashiCorp, Inc. |
| 2 | +// SPDX-License-Identifier: MPL-2.0 |
| 3 | +// Copyright (c) HashiCorp, Inc. |
| 4 | +// SPDX-License-Identifier: MPL-2.0 |
| 5 | +package bigquery_test |
| 6 | + |
| 7 | +import ( |
| 8 | + "testing" |
| 9 | + |
| 10 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 11 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 12 | +) |
| 13 | + |
| 14 | +func TestAccDataSourceGoogleBigqueryDataset_basic(t *testing.T) { |
| 15 | + t.Parallel() |
| 16 | + |
| 17 | + context := map[string]interface{}{ |
| 18 | + "random_suffix": acctest.RandString(t, 10), |
| 19 | + } |
| 20 | + |
| 21 | + acctest.VcrTest(t, resource.TestCase{ |
| 22 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 23 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 24 | + CheckDestroy: testAccCheckBigQueryDatasetDestroyProducer(t), |
| 25 | + Steps: []resource.TestStep{ |
| 26 | + { |
| 27 | + Config: testAccDataSourceGoogleBigqueryDataset_basic(context), |
| 28 | + Check: resource.ComposeTestCheckFunc( |
| 29 | + acctest.CheckDataSourceStateMatchesResourceState("data.google_bigquery_dataset.bar", "google_bigquery_dataset.foo"), |
| 30 | + ), |
| 31 | + }, |
| 32 | + }, |
| 33 | + }) |
| 34 | +} |
| 35 | + |
| 36 | +func testAccDataSourceGoogleBigqueryDataset_basic(context map[string]interface{}) string { |
| 37 | + return acctest.Nprintf(` |
| 38 | +
|
| 39 | + resource "google_bigquery_dataset" "foo" { |
| 40 | + dataset_id = "tf_test_ds_%{random_suffix}" |
| 41 | + friendly_name = "testing" |
| 42 | + description = "This is a test description" |
| 43 | + location = "US" |
| 44 | + default_table_expiration_ms = 3600000 |
| 45 | + } |
| 46 | +
|
| 47 | + data "google_bigquery_dataset" "bar" { |
| 48 | + dataset_id = google_bigquery_dataset.foo.dataset_id |
| 49 | + } |
| 50 | +`, context) |
| 51 | +} |
0 commit comments