github.com/gabrielperezs/terraform@v0.7.0-rc2.0.20160715084931-f7da2612946f/builtin/providers/aws/tagsRedshift_test.go (about) 1 package aws 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 func TestDiffRedshiftTags(t *testing.T) { 9 cases := []struct { 10 Old, New map[string]interface{} 11 Create, Remove map[string]string 12 }{ 13 { 14 Old: map[string]interface{}{ 15 "foo": "bar", 16 }, 17 New: map[string]interface{}{ 18 "bar": "baz", 19 }, 20 Create: map[string]string{ 21 "bar": "baz", 22 }, 23 Remove: map[string]string{ 24 "foo": "bar", 25 }, 26 }, 27 { 28 Old: map[string]interface{}{ 29 "foo": "bar", 30 }, 31 New: map[string]interface{}{ 32 "foo": "baz", 33 }, 34 Create: map[string]string{ 35 "foo": "baz", 36 }, 37 Remove: map[string]string{ 38 "foo": "bar", 39 }, 40 }, 41 } 42 43 for i, tc := range cases { 44 c, r := diffTagsRedshift(tagsFromMapRedshift(tc.Old), tagsFromMapRedshift(tc.New)) 45 cm := tagsToMapRedshift(c) 46 rm := tagsToMapRedshift(r) 47 if !reflect.DeepEqual(cm, tc.Create) { 48 t.Fatalf("%d: bad create: %#v", i, cm) 49 } 50 if !reflect.DeepEqual(rm, tc.Remove) { 51 t.Fatalf("%d: bad remove: %#v", i, rm) 52 } 53 } 54 }