@@ -404,3 +404,43 @@ func TestDatasourceSchemaFromResourceSchema(t *testing.T) {
404
404
})
405
405
}
406
406
}
407
+
408
+ func TestEmptyOrDefaultStringSuppress (t * testing.T ) {
409
+ testFunc := emptyOrDefaultStringSuppress ("default value" )
410
+
411
+ cases := map [string ]struct {
412
+ Old , New string
413
+ ExpectDiffSupress bool
414
+ }{
415
+ "same value, format changed from empty to default" : {
416
+ Old : "" ,
417
+ New : "default value" ,
418
+ ExpectDiffSupress : true ,
419
+ },
420
+ "same value, format changed from default to empty" : {
421
+ Old : "default value" ,
422
+ New : "" ,
423
+ ExpectDiffSupress : true ,
424
+ },
425
+ "different value, format changed from empty to non-default" : {
426
+ Old : "" ,
427
+ New : "not default new" ,
428
+ ExpectDiffSupress : false ,
429
+ },
430
+ "different value, format changed from non-default to empty" : {
431
+ Old : "not default old" ,
432
+ New : "" ,
433
+ ExpectDiffSupress : false ,
434
+ },
435
+ "different value, format changed from non-default to non-default" : {
436
+ Old : "not default 1" ,
437
+ New : "not default 2" ,
438
+ ExpectDiffSupress : false ,
439
+ },
440
+ }
441
+ for tn , tc := range cases {
442
+ if testFunc ("" , tc .Old , tc .New , nil ) != tc .ExpectDiffSupress {
443
+ t .Errorf ("bad: %s, '%s' => '%s' expect DiffSuppress to return %t" , tn , tc .Old , tc .New , tc .ExpectDiffSupress )
444
+ }
445
+ }
446
+ }
0 commit comments