matcher

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package matcher provides functionalities for matching header and body.

Index

Constants

This section is empty.

Variables

View Source
var Exact = matcher.Exact

Exact matches two objects by their exact values.

View Source
var IsNotEmpty = matcher.IsNotEmpty

IsNotEmpty checks whether the value is not empty.

View Source
var JSON = matcher.JSON

JSON matches two json strings with <ignore-diff> support.

View Source
var Match = matcher.Match

Match returns a matcher according to its type.

View Source
var Regex = matcher.Regex

Regex matches two strings by using regex.

View Source
var RegexPattern = matcher.RegexPattern

RegexPattern matches two strings by using regex.

Functions

This section is empty.

Types

type BodyMatcher

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

BodyMatcher matches a body of a request.

func Body

func Body(v interface{}) *BodyMatcher

Body initiates a new body matcher.

func (BodyMatcher) Actual

func (m BodyMatcher) Actual() string

Actual returns the decoded input.

func (BodyMatcher) Expected

func (m BodyMatcher) Expected() string

Expected returns the expectation.

func (*BodyMatcher) Match

func (m *BodyMatcher) Match(in interface{}) (bool, error)

Match satisfies matcher.Matcher interface.

func (*BodyMatcher) Matcher

func (m *BodyMatcher) Matcher() matcher.Matcher

Matcher returns the underlay matcher.

type Callback

type Callback = matcher.Callback

Callback matches by calling a function.

type ExactMatcher

type ExactMatcher = matcher.ExactMatcher

ExactMatcher matches by exact string.

type FnMatcher

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

FnMatcher is a matcher that call itself.

func Fn

func Fn(expected string, match func(actual interface{}) (bool, error)) FnMatcher

Fn creates a new FnMatcher matcher.

func (FnMatcher) Expected

func (f FnMatcher) Expected() string

Expected satisfies the matcher.Matcher interface.

func (FnMatcher) Match

func (f FnMatcher) Match(actual interface{}) (bool, error)

Match satisfies the matcher.Matcher interface.

type HeaderMatcher

type HeaderMatcher map[string]Matcher

HeaderMatcher matches the header values.

func (HeaderMatcher) Match

func (m HeaderMatcher) Match(header http.Header) error

Match matches the header in context.

type Matcher

type Matcher = matcher.Matcher

Matcher determines if the actual matches the expectation.

Jump to

Keyboard shortcuts

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