-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
- Loading branch information
1 parent
8163b44
commit 64779ae
Showing
4 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:bug | ||
bigquery: fixed an issue in `google_bigquery_job` where non-US locations could not be read | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccBigQueryJob_withLocation(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": randString(t, 10), | ||
"location": "asia-northeast1", | ||
} | ||
|
||
// Need to construct the import ID manually since the state ID will not contain the location | ||
importID := fmt.Sprintf("projects/%s/jobs/tf_test_job_query%s/location/%s", getTestProjectFromEnv(), context["random_suffix"], context["location"]) | ||
|
||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
ExternalProviders: map[string]resource.ExternalProvider{ | ||
"random": {}, | ||
}, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccBigQueryJob_withLocation(context), | ||
}, | ||
{ | ||
ResourceName: "google_bigquery_job.job", | ||
ImportStateId: importID, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"etag"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccBigQueryJob_withLocation(context map[string]interface{}) string { | ||
return Nprintf(` | ||
resource "google_bigquery_table" "foo" { | ||
dataset_id = google_bigquery_dataset.bar.dataset_id | ||
table_id = "tf_test_job_query%{random_suffix}_table" | ||
} | ||
resource "google_bigquery_dataset" "bar" { | ||
dataset_id = "tf_test_job_query%{random_suffix}_dataset" | ||
friendly_name = "test" | ||
description = "This is a test description" | ||
location = "%{location}" | ||
} | ||
resource "google_bigquery_job" "job" { | ||
job_id = "tf_test_job_query%{random_suffix}" | ||
labels = { | ||
"example-label" ="example-value" | ||
} | ||
query { | ||
query = "SELECT state FROM [lookerdata:cdc.project_tycho_reports]" | ||
destination_table { | ||
project_id = google_bigquery_table.foo.project | ||
dataset_id = google_bigquery_table.foo.dataset_id | ||
table_id = google_bigquery_table.foo.table_id | ||
} | ||
allow_large_results = true | ||
flatten_results = true | ||
script_options { | ||
key_result_statement = "LAST" | ||
} | ||
} | ||
location = "%{location}" | ||
} | ||
`, context) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters