udpate some tests with unexported gocmp options

This commit is contained in:
James Bardin 2020-12-01 14:07:36 -05:00
parent 913f6c2091
commit 15dad81e2b
2 changed files with 12 additions and 4 deletions

View File

@ -5,11 +5,19 @@ import (
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
proto "github.com/hashicorp/terraform/internal/tfplugin5"
"github.com/hashicorp/terraform/tfdiags"
"github.com/zclconf/go-cty/cty"
)
var ignoreUnexported = cmpopts.IgnoreUnexported(
proto.Diagnostic{},
proto.Schema_Block{},
proto.Schema_NestedBlock{},
proto.Schema_Attribute{},
)
func TestProtoDiagnostics(t *testing.T) {
diags := WarnsAndErrsToProto(
[]string{
@ -41,8 +49,8 @@ func TestProtoDiagnostics(t *testing.T) {
},
}
if !cmp.Equal(expected, diags) {
t.Fatal(cmp.Diff(expected, diags))
if !cmp.Equal(expected, diags, ignoreUnexported) {
t.Fatal(cmp.Diff(expected, diags, ignoreUnexported))
}
}

View File

@ -353,8 +353,8 @@ func TestConvertProtoSchemaBlocks(t *testing.T) {
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
converted := ConfigSchemaToProto(tc.Block)
if !cmp.Equal(converted, tc.Want, typeComparer, equateEmpty) {
t.Fatal(cmp.Diff(converted, tc.Want, typeComparer, equateEmpty))
if !cmp.Equal(converted, tc.Want, typeComparer, equateEmpty, ignoreUnexported) {
t.Fatal(cmp.Diff(converted, tc.Want, typeComparer, equateEmpty, ignoreUnexported))
}
})
}