Skip to content

Commit

Permalink
Added policyTags test for bigquery table schema customizediff func (#…
Browse files Browse the repository at this point in the history
…4844) (#3315)

The behavior here is correct but this is an edge case we could accidentally run into in the future.

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jun 4, 2021
1 parent 4c07af1 commit f7c95b3
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/4844.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
51 changes: 37 additions & 14 deletions google-beta/resource_bigquery_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,20 +916,6 @@ func TestAccBigQueryDataTable_expandArray(t *testing.T) {
})
}

func TestUnitBigQueryDataTable_schemaIsChangable(t *testing.T) {
t.Parallel()
for _, testcase := range testUnitBigQueryDataTableIsChangableTestCases {
testcase.check(t)
testcaseNested := &testUnitBigQueryDataTableJSONChangeableTestCase{
testcase.name + "Nested",
fmt.Sprintf("[{\"name\": \"someValue\", \"type\" : \"INTEGER\", \"fields\" : %s }]", testcase.jsonOld),
fmt.Sprintf("[{\"name\": \"someValue\", \"type\" : \"INT64\", \"fields\" : %s }]", testcase.jsonNew),
testcase.changeable,
}
testcaseNested.check(t)
}
}

func TestAccBigQueryTable_allowDestroy(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -1081,6 +1067,43 @@ var testUnitBigQueryDataTableIsChangableTestCases = []testUnitBigQueryDataTableJ
jsonNew: "[{\"name\": \"value3\", \"type\" : \"BOOLEAN\", \"mode\" : \"NULLABLE\", \"description\" : \"newVal\" }, {\"name\": \"value1\", \"type\" : \"INTEGER\", \"mode\" : \"NULLABLE\", \"description\" : \"someVal\" }]",
changeable: false,
},
{
name: "policyTags",
jsonOld: `[
{
"mode": "NULLABLE",
"name": "providerphone",
"policyTags": {
"names": ["projects/my-project/locations/us/taxonomies/12345678/policyTags/12345678"]
},
"type":"STRING"
}
]`,
jsonNew: `[
{
"name": "providerphone",
"type": "STRING",
"policyTags": {
"names": ["projects/my-project/locations/us/taxonomies/12345678/policyTags/12345678"]
}
}
]`,
changeable: true,
},
}

func TestUnitBigQueryDataTable_schemaIsChangable(t *testing.T) {
t.Parallel()
for _, testcase := range testUnitBigQueryDataTableIsChangableTestCases {
testcase.check(t)
testcaseNested := &testUnitBigQueryDataTableJSONChangeableTestCase{
testcase.name + "Nested",
fmt.Sprintf("[{\"name\": \"someValue\", \"type\" : \"INTEGER\", \"fields\" : %s }]", testcase.jsonOld),
fmt.Sprintf("[{\"name\": \"someValue\", \"type\" : \"INT64\", \"fields\" : %s }]", testcase.jsonNew),
testcase.changeable,
}
testcaseNested.check(t)
}
}

func testAccCheckBigQueryExtData(t *testing.T, expectedQuoteChar string) resource.TestCheckFunc {
Expand Down

0 comments on commit f7c95b3

Please sign in to comment.