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