Skip to content

Commit fc9e5d6

Browse files
authored
Rename ProtoContains to ProtoConsitsOf (#26)
1 parent 7290afe commit fc9e5d6

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

matchers.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ func ProtoEqual(expected proto.Message) types.GomegaMatcher {
4949
}
5050
}
5151

52-
// ProtoContainsMatcher is a custom Gomega matcher to check if a slice of protocol buffers contains specific elements
53-
type ProtoContainsMatcher struct {
52+
// ProtoConsistOfMatcher is a custom Gomega matcher to check if a slice of protocol buffers contains specific elements
53+
type ProtoConsistOfMatcher struct {
5454
Elements []proto.Message
5555
}
5656

57-
func (matcher *ProtoContainsMatcher) Match(actual interface{}) (success bool, err error) {
57+
func (matcher *ProtoConsistOfMatcher) Match(actual interface{}) (success bool, err error) {
5858
v := reflect.ValueOf(actual)
5959
if v.Kind() != reflect.Slice {
6060
return false, nil
@@ -87,15 +87,15 @@ func (matcher *ProtoContainsMatcher) Match(actual interface{}) (success bool, er
8787
return true, nil
8888
}
8989

90-
func (matcher *ProtoContainsMatcher) FailureMessage(actual interface{}) (message string) {
90+
func (matcher *ProtoConsistOfMatcher) FailureMessage(actual interface{}) (message string) {
9191
return format.Message(actual, "to contain elements", matcher.Elements)
9292
}
9393

94-
func (matcher *ProtoContainsMatcher) NegatedFailureMessage(actual interface{}) (message string) {
94+
func (matcher *ProtoConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) {
9595
return format.Message(actual, "not to contain elements", matcher.Elements)
9696
}
9797

98-
// ProtoContains returns a Gomega matcher that checks if a slice of Protobuf messages contains all the specified elements.
98+
// ProtoConsistOf returns a Gomega matcher that checks if a slice of Protobuf messages contains all the specified elements.
9999
// It verifies that the input is a slice of proto.Message implementations and that each specified element is present in the
100100
// actual slice (in any order), using proto.Equal for comparisons. The actual slice may contain additional elements beyond
101101
// those specified.
@@ -106,16 +106,16 @@ func (matcher *ProtoContainsMatcher) NegatedFailureMessage(actual interface{}) (
106106
//
107107
// Example usage:
108108
//
109-
// Expect(items).To(ProtoContains(
109+
// Expect(items).To(ProtoConsistOf(
110110
// &v1.Foo{Bar: "test1"},
111111
// &v1.Foo{Bar: "test2"},
112112
// )) // Passes if items contains both elements (and possibly more)
113-
// Expect(missing).ToNot(ProtoContains(
113+
// Expect(missing).ToNot(ProtoConsistOf(
114114
// &v1.Foo{Bar: "test1"},
115115
// &v1.Foo{Bar: "test2"},
116116
// )) // Passes if missing lacks at least one of these elements
117-
func ProtoContains(elements ...proto.Message) types.GomegaMatcher {
118-
return &ProtoContainsMatcher{
117+
func ProtoConsistOf(elements ...proto.Message) types.GomegaMatcher {
118+
return &ProtoConsistOfMatcher{
119119
Elements: elements,
120120
}
121121
}

matchers_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func TestProtoEqualMatcher(t *testing.T) {
9797
func TestProtoContainsMatcher(t *testing.T) {
9898
g := gomega.NewWithT(t)
9999

100-
// Define test cases for ProtoContains
100+
// Define test cases for ProtoConsistOf
101101
testCases := []struct {
102102
name string
103103
actual interface{}
@@ -215,9 +215,9 @@ func TestProtoContainsMatcher(t *testing.T) {
215215
for _, tc := range testCases {
216216
t.Run(tc.name, func(t *testing.T) {
217217
if tc.shouldMatch {
218-
g.Expect(tc.actual).To(matchers.ProtoContains(tc.elements...))
218+
g.Expect(tc.actual).To(matchers.ProtoConsistOf(tc.elements...))
219219
} else {
220-
g.Expect(tc.actual).ToNot(matchers.ProtoContains(tc.elements...))
220+
g.Expect(tc.actual).ToNot(matchers.ProtoConsistOf(tc.elements...))
221221
}
222222
})
223223
}

0 commit comments

Comments
 (0)