use a custom comparer for cty.Type

Make sure we also compare cty.Types in `cmp.Equal`, even though they
contain unexported fields.
This commit is contained in:
James Bardin 2018-07-11 22:34:39 -04:00 committed by Martin Atkins
parent 3112b707be
commit 15ccf2dda5
2 changed files with 6 additions and 6 deletions

View File

@ -11,8 +11,8 @@ import (
)
var (
ignoreUnexported = cmpopts.IgnoreUnexported(cty.Type{})
equateEmpty = cmpopts.EquateEmpty()
typeComparer = cmp.Comparer(cty.Type.Equals)
)
// add the implicit "id" attribute for test resources
@ -305,8 +305,8 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
for name, test := range tests {
t.Run(name, func(t *testing.T) {
got := schemaMap(test.Schema).CoreConfigSchema()
if !cmp.Equal(got, test.Want, equateEmpty, ignoreUnexported) {
cmp.Diff(got, test.Want, equateEmpty, ignoreUnexported)
if !cmp.Equal(got, test.Want, typeComparer) {
cmp.Diff(got, test.Want, typeComparer)
}
})
}

View File

@ -91,8 +91,8 @@ func TestProviderGetSchema(t *testing.T) {
t.Fatalf("unexpected error %s", err)
}
if !cmp.Equal(got, want, equateEmpty, ignoreUnexported) {
t.Error("wrong result:\n", cmp.Diff(got, want, equateEmpty, ignoreUnexported))
if !cmp.Equal(got, want, equateEmpty, typeComparer) {
t.Error("wrong result:\n", cmp.Diff(got, want, equateEmpty, typeComparer))
}
}