matcher

package
v0.0.0-...-af4311f Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ExistsMatcher defines special matcher to match non-existent key
	// e.g.
	// matcher:
	// {
	//   "string": {
	//     "$exists": true
	//   }
	// }
	// data:
	// {
	//   "string": "string"
	// }
	ExistsMatcher = "$exists"

	// RegexpMatcher defines matcher to match regexp
	// e.g.
	// matcher:
	// {
	//   "string": {
	//     "$regexp": "[a-z]*"
	//   }
	// }
	// data:
	// {
	//   "string": "string"
	// }
	RegexpMatcher = "$regexp"

	// MatchMatcher defines matcher matches original data
	// e.g.
	// matcher:
	// {
	//   "string": {
	//     "$match": "string"
	//   }
	// }
	// data:
	// {
	//   "string": "string"
	// }
	MatchMatcher = "$match"

	// LenMatcher defines matcher matches length of data
	// support string, object, array
	// e.g.
	// matcher:
	// {
	//   "string": {
	//     "$len": 4
	//   }
	// }
	// data:
	// {
	//   "string": "1234"
	// }
	LenMatcher = "$len"
)

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.

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.

func MatchSpecial

func MatchSpecial(ms map[string]types.GomegaMatcher) types.GomegaMatcher

MatchSpecial combine multiple special matchers into one matcher

func Parse

func Parse(matcher []byte) (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 SliceMatcher

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

SliceMatcher 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 (*SliceMatcher) FailureMessage

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

FailureMessage implements types.GomegaMatcher

func (*SliceMatcher) Failures

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

Failures returns failures of matcher

func (*SliceMatcher) Match

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

Match implements gomega.Matcher

func (*SliceMatcher) NegatedFailureMessage

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

NegatedFailureMessage implements types.GomegaMatcher

type SpecialMatcher

type SpecialMatcher struct {
	// contains filtered or unexported fields
}

SpecialMatcher match one by one

func (*SpecialMatcher) FailureMessage

func (sp *SpecialMatcher) FailureMessage(actual interface{}) (message string)

FailureMessage implements types.GomegaMatcher

func (*SpecialMatcher) Failures

func (sp *SpecialMatcher) Failures() []error

Failures returns failures of matcher

func (*SpecialMatcher) Match

func (sp *SpecialMatcher) Match(actual interface{}) (bool, error)

Match implements types.GomegaMatcher

func (*SpecialMatcher) NegatedFailureMessage

func (sp *SpecialMatcher) 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