Skip to content

Commit

Permalink
helper/schema: More tests for Set.HashEqual
Browse files Browse the repository at this point in the history
Just to make sure equality on outer and inner values does not affect
anything.
  • Loading branch information
vancluever committed Aug 16, 2017
1 parent ca42980 commit 287a5eb
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions helper/schema/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,18 @@ func TestHashEqual(t *testing.T) {
"bar": "qux",
"nested": NewSet(HashResource(nested), []interface{}{n2}),
}
r3 := map[string]interface{}{
"bar": "baz",
"nested": NewSet(HashResource(nested), []interface{}{n2}),
}
r4 := map[string]interface{}{
"bar": "qux",
"nested": NewSet(HashResource(nested), []interface{}{n1}),
}
s1 := NewSet(HashResource(root), []interface{}{r1})
s2 := NewSet(HashResource(root), []interface{}{r2})
s3 := NewSet(HashResource(root), []interface{}{r3})
s4 := NewSet(HashResource(root), []interface{}{r4})

cases := []struct {
name string
Expand All @@ -183,6 +193,18 @@ func TestHashEqual(t *testing.T) {
compare: s2,
expected: false,
},
{
name: "outer equal, should still not be equal",
set: s1,
compare: s3,
expected: false,
},
{
name: "inner equal, should still not be equal",
set: s1,
compare: s4,
expected: false,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 287a5eb

Please sign in to comment.