9
9
"testing"
10
10
"time"
11
11
12
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
12
13
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
13
14
"github.com/hashicorp/terraform-plugin-testing/terraform"
14
15
"github.com/hashicorp/terraform-provider-google/google/services/dataflow"
@@ -25,7 +26,7 @@ import (
25
26
)
26
27
27
28
const (
28
- testDataflowJobTemplateWordCountUrl = "gs://dataflow-templates-us-central1 /latest/Word_Count"
29
+ testDataflowJobTemplateWordCountUrl = "gs://dataflow-templates/latest/Word_Count"
29
30
testDataflowJobSampleFileUrl = "gs://dataflow-samples/shakespeare/various.txt"
30
31
testDataflowJobTemplateTextToPubsub = "gs://dataflow-templates-us-central1/latest/Stream_GCS_Text_to_Cloud_PubSub"
31
32
testDataflowJobRegion = "us-central1"
@@ -1371,3 +1372,39 @@ resource "google_dataflow_job" "pubsub_stream" {
1371
1372
}
1372
1373
`, suffix, suffix, suffix, testDataflowJobTemplateTextToPubsub, onDelete)
1373
1374
}
1375
+
1376
+ func TestResourceDataflowJobTemplateGcsPathDiffSuppress(t *testing.T) {
1377
+ cases := map[string]struct {
1378
+ Old, New string
1379
+ ExpectDiffSuppress bool
1380
+ }{
1381
+ "same bucket": {
1382
+ Old: "gs://template-bucket/path/to/file",
1383
+ New: "gs://template-bucket/path/to/file",
1384
+ ExpectDiffSuppress: true,
1385
+ },
1386
+ "different bucket": {
1387
+ Old: "gs://template-bucket-foo/path/to/file1",
1388
+ New: "gs://template-bucket/path/to/file1",
1389
+ ExpectDiffSuppress: false,
1390
+ },
1391
+ "different object": {
1392
+ Old: "gs://template-bucket-foo/path/to/file2",
1393
+ New: "gs://template-bucket/path/to/file",
1394
+ ExpectDiffSuppress: false,
1395
+ },
1396
+ "regional bucket name change is okay": {
1397
+ Old: "gs://template-bucket-us-central1/path/to/file1",
1398
+ New: "gs://template-bucket/path/to/file1",
1399
+ ExpectDiffSuppress: true,
1400
+ },
1401
+ }
1402
+ rd := schema.TestResourceDataRaw(t, dataflow.ResourceDataflowJob().Schema, nil)
1403
+ rd.Set("region", "us-central1")
1404
+
1405
+ for tn, tc := range cases {
1406
+ if dataflow.ResourceDataflowJobTemplateGcsPathDiffSuppress("template_gcs_path", tc.Old, tc.New, rd) != tc.ExpectDiffSuppress {
1407
+ t.Errorf("bad: %s, '%s' => '%s' expect DiffSuppress to return %t", tn, tc.Old, tc.New, tc.ExpectDiffSuppress)
1408
+ }
1409
+ }
1410
+ }
0 commit comments