matcher

package
v0.0.0-...-8472c8c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExistsMatcher defines special matcher to match non-existent key
	ExistsMatcher = "$exists"

	// RegexpMatcher defines matcher to match regexp
	RegexpMatcher = "$regexp"
)

Variables

This section is empty.

Functions

func MatchMap

func MatchMap(fields Fields, exists map[string]bool) types.GomegaMatcher

MatchMap succeeds if every field of a struct matches the field matcher associated with it, and every element matcher is matched.

Expect([]string{"a", "b"}).To(MatchAllFields(idFn, gstruct.Fields{
    "a": BeEqual("a"),
    "b": BeEqual("b"),
})

func MatchSlice

func MatchSlice(elements Elements) types.GomegaMatcher

MatchSlice succeeds if every element of a slice matches the element matcher it maps to through the id function, and every element matcher is matched.

Expect([]string{"a", "b"}).To(MatchAllElements(idFn, matchers.Elements{
    "a": BeEqual("a"),
    "b": BeEqual("b"),
})

func Parse

func Parse(matcher string) (gomegatypes.GomegaMatcher, error)

Parse parse matcher of response and returns GomegaMatcher

Types

type Elements

type Elements []types.GomegaMatcher

Elements ID to matcher.

type Fields

type Fields map[string]types.GomegaMatcher

Fields name to matcher.

type FieldsMatcher

type FieldsMatcher struct {
	// Matchers for each field.
	Fields Fields

	// Exists defines existence of fields
	// If field is not in it, it will not be
	// checked for existence
	Exists map[string]bool
	// contains filtered or unexported fields
}

FieldsMatcher for map

func (*FieldsMatcher) FailureMessage

func (m *FieldsMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage implements types.GomegaMatcher

func (*FieldsMatcher) Failures

func (m *FieldsMatcher) Failures() []error

Failures returns all errors

func (*FieldsMatcher) Match

func (m *FieldsMatcher) Match(actual interface{}) (success bool, err error)

Match implements types.GomegaMatcher

func (*FieldsMatcher) NegatedFailureMessage

func (m *FieldsMatcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage implements types.GomegaMatcher

type Matcher

type Matcher struct {
	// Matchers for each element.
	Elements Elements
	// contains filtered or unexported fields
}

Matcher is a NestingMatcher that applies custom matchers to each element of a slice mapped by the Identifier function. TODO: Extend this to work with arrays & maps (map the key) as well.

func (*Matcher) FailureMessage

func (m *Matcher) FailureMessage(actual interface{}) (message string)

FailureMessage implements types.GomegaMatcher

func (*Matcher) Failures

func (m *Matcher) Failures() []error

Failures returns failures of matcher

func (*Matcher) Match

func (m *Matcher) Match(actual interface{}) (success bool, err error)

Match implements gomega.Matcher

func (*Matcher) NegatedFailureMessage

func (m *Matcher) NegatedFailureMessage(actual interface{}) (message string)

NegatedFailureMessage implements types.GomegaMatcher

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL