helper/schema: More tests for Set.HashEqual

Just to make sure equality on outer and inner values does not affect
anything.
This commit is contained in:
Chris Marchesi 2017-08-15 21:56:01 -07:00
parent ca42980e49
commit 287a5eb66a
No known key found for this signature in database
GPG Key ID: 335B84AFEC615CE4
1 changed files with 22 additions and 0 deletions

View File

@ -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
@ -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) {