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:
parent
3112b707be
commit
15ccf2dda5
|
@ -11,8 +11,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ignoreUnexported = cmpopts.IgnoreUnexported(cty.Type{})
|
equateEmpty = cmpopts.EquateEmpty()
|
||||||
equateEmpty = cmpopts.EquateEmpty()
|
typeComparer = cmp.Comparer(cty.Type.Equals)
|
||||||
)
|
)
|
||||||
|
|
||||||
// add the implicit "id" attribute for test resources
|
// add the implicit "id" attribute for test resources
|
||||||
|
@ -305,8 +305,8 @@ func TestSchemaMapCoreConfigSchema(t *testing.T) {
|
||||||
for name, test := range tests {
|
for name, test := range tests {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
got := schemaMap(test.Schema).CoreConfigSchema()
|
got := schemaMap(test.Schema).CoreConfigSchema()
|
||||||
if !cmp.Equal(got, test.Want, equateEmpty, ignoreUnexported) {
|
if !cmp.Equal(got, test.Want, typeComparer) {
|
||||||
cmp.Diff(got, test.Want, equateEmpty, ignoreUnexported)
|
cmp.Diff(got, test.Want, typeComparer)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,8 +91,8 @@ func TestProviderGetSchema(t *testing.T) {
|
||||||
t.Fatalf("unexpected error %s", err)
|
t.Fatalf("unexpected error %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cmp.Equal(got, want, equateEmpty, ignoreUnexported) {
|
if !cmp.Equal(got, want, equateEmpty, typeComparer) {
|
||||||
t.Error("wrong result:\n", cmp.Diff(got, want, equateEmpty, ignoreUnexported))
|
t.Error("wrong result:\n", cmp.Diff(got, want, equateEmpty, typeComparer))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue