Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProtoConsistOf ¶ added in v0.1.7
func ProtoConsistOf(elements ...proto.Message) types.GomegaMatcher
ProtoConsistOf returns a Gomega matcher that checks if a slice of Protobuf messages contains all the specified elements. It verifies that the input is a slice of proto.Message implementations and that each specified element is present in the actual slice (in any order), using proto.Equal for comparisons. The actual slice may contain additional elements beyond those specified.
This matcher is useful for testing scenarios where you want to ensure certain Protobuf messages are present in a collection, regardless of order or additional elements. It accepts variadic arguments, allowing individual elements to be passed directly.
Example usage:
Expect(items).To(ProtoConsistOf( &v1.Foo{Bar: "test1"}, &v1.Foo{Bar: "test2"}, )) // Passes if items contains both elements (and possibly more) Expect(missing).ToNot(ProtoConsistOf( &v1.Foo{Bar: "test1"}, &v1.Foo{Bar: "test2"}, )) // Passes if missing lacks at least one of these elements
func ProtoEqual ¶
func ProtoEqual(expected proto.Message) types.GomegaMatcher
ProtoEqual returns a Gomega matcher that checks if a Protobuf message is equal to the expected message. It verifies that the input implements proto.Message and matches the expected message using proto.Equal. If the input is not a proto.Message or does not match the expected message, the matcher fails.
This matcher is useful for testing scenarios where a single Protobuf message should exactly match an expected template. It performs a deep comparison of all fields, including nested messages, as defined by proto.Equal.
Example usage:
expected := &v1.Foo{Bar: "test", Baz: "baz"} item := &v1.Foo{Bar: "test", Baz: "baz"} Expect(item).To(ProtoEqual(expected)) // Passes mismatched := &v1.Foo{Bar: "different", Baz: "baz"} Expect(mismatched).ToNot(ProtoEqual(expected)) // Passes
Types ¶
type ProtoConsistOfMatcher ¶ added in v0.1.7
ProtoConsistOfMatcher is a custom Gomega matcher to check if a slice of protocol buffers contains specific elements
func (*ProtoConsistOfMatcher) FailureMessage ¶ added in v0.1.7
func (matcher *ProtoConsistOfMatcher) FailureMessage(actual interface{}) (message string)
func (*ProtoConsistOfMatcher) Match ¶ added in v0.1.7
func (matcher *ProtoConsistOfMatcher) Match(actual interface{}) (success bool, err error)
func (*ProtoConsistOfMatcher) NegatedFailureMessage ¶ added in v0.1.7
func (matcher *ProtoConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string)
type ProtoEqualMatcher ¶
ProtoEqualMatcher is a custom Gomega matcher for protocol buffers
func (*ProtoEqualMatcher) FailureMessage ¶
func (matcher *ProtoEqualMatcher) FailureMessage(actual interface{}) (message string)
func (*ProtoEqualMatcher) Match ¶
func (matcher *ProtoEqualMatcher) Match(actual interface{}) (success bool, err error)
func (*ProtoEqualMatcher) NegatedFailureMessage ¶
func (matcher *ProtoEqualMatcher) NegatedFailureMessage(actual interface{}) (message string)