testing: slightly better comparison for x509.CertPool

pull/10165/head
Daniel Nephin 4 years ago
parent f5afed82c8
commit 0624c75c56

@ -7,7 +7,6 @@ import (
"testing" "testing"
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/hashicorp/consul/agent" "github.com/hashicorp/consul/agent"
@ -295,11 +294,11 @@ func requireEqualTLSConfig(t *testing.T, expect, got *tls.Config) {
require.Equal(expectLeaf, gotLeaf) require.Equal(expectLeaf, gotLeaf)
} }
// lazyCerts has a func field which can't be compared. // cmpCertPool is a custom comparison for x509.CertPool, because CertPool.lazyCerts
var cmpCertPool = cmp.Options{ // has a func field which can't be compared.
cmpopts.IgnoreFields(x509.CertPool{}, "lazyCerts"), var cmpCertPool = cmp.Comparer(func(x, y *x509.CertPool) bool {
cmp.AllowUnexported(x509.CertPool{}), return cmp.Equal(x.Subjects(), y.Subjects())
} })
func assertDeepEqual(t *testing.T, x, y interface{}, opts ...cmp.Option) { func assertDeepEqual(t *testing.T, x, y interface{}, opts ...cmp.Option) {
t.Helper() t.Helper()

Loading…
Cancel
Save