Skip to content

Commit

Permalink
structmatcher: Use MatchStruct matcher in deprecated implementations
Browse files Browse the repository at this point in the history
This also removes the dependency on ginkgo, which will improve
compatibility with ginkgo v2.

Authored-by: David Sharp <dsharp@vmware.com>
  • Loading branch information
dsharp-pivotal authored and jimmyyih committed Apr 25, 2022
1 parent c24a3ea commit b48b881
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions structmatcher/structmatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"reflect"
"strings"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/types"
)
Expand Down Expand Up @@ -106,26 +105,17 @@ func structMatcher(expected, actual reflect.Value, fieldPath string, shouldFilte

// Deprecated: Use structmatcher.MatchStruct() GomegaMatcher
func ExpectStructsToMatch(expected interface{}, actual interface{}) {
mismatches := StructMatcher(expected, actual, false, false)
if len(mismatches) > 0 {
Fail(strings.Join(mismatches, "\n"))
}
Expect(actual).To(MatchStruct(expected))
}

// Deprecated: Use structmatcher.MatchStruct().ExcludingFields() GomegaMatcher
func ExpectStructsToMatchExcluding(expected interface{}, actual interface{}, excludeFields ...string) {
mismatches := StructMatcher(expected, actual, true, false, excludeFields...)
if len(mismatches) > 0 {
Fail(strings.Join(mismatches, "\n"))
}
Expect(actual).To(MatchStruct(expected).ExcludingFields(excludeFields...))
}

// Deprecated: Use structmatcher.MatchStruct().IncludingFields() GomegaMatcher
func ExpectStructsToMatchIncluding(expected interface{}, actual interface{}, includeFields ...string) {
mismatches := StructMatcher(expected, actual, true, true, includeFields...)
if len(mismatches) > 0 {
Fail(strings.Join(mismatches, "\n"))
}
Expect(actual).To(MatchStruct(expected).IncludingFields(includeFields...))
}

type Matcher struct {
Expand Down

0 comments on commit b48b881

Please sign in to comment.