matcher

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Text matcher type
	Text = "text"
	// Pattern matcher type
	Pattern = "pattern"
	// Contains matcher type
	Contains = "contains"
	// Equal matcher type
	Equal = "equal"
	// GreaterThanOrEqual matcher type
	GreaterThanOrEqual = "greaterthanorequal"
	// LessThanOrEqual matcher type
	LessThanOrEqual = "lessthanorequal"
	// Not contains matcher type
	NotContains = "notcontains"
	JSON        = "json"
	XML         = "xml"
	File        = "file"
)

Variables

View Source
var (
	PatternPrefix = "r/"
)
View Source
var ReadFile = ioutil.ReadFile

The function used to open files when necessary for matching Allows the file IO to be overridden during tests

Functions

func CompilePattern added in v3.0.1

func CompilePattern(expr string) (*regexp.Regexp, error)

func ExpandEnv added in v3.0.1

func ExpandEnv(v string) string

func IsMatch added in v3.0.1

func IsMatch(value interface{}, pattern string) bool

func IsPattern added in v3.0.1

func IsPattern(v string) bool

Types

type ContainsMatcher

type ContainsMatcher struct {
}

ContainsMatcher tests if the expected value is in the got variable

func (ContainsMatcher) Match

func (m ContainsMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches on the given values

type EqualMatcher

type EqualMatcher struct {
}

EqualMatcher matches if given values are equal

func (EqualMatcher) Match

func (m EqualMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches the values if they are equal

type FileMatcher

type FileMatcher struct {
}

FileMatcher matches output captured from stdout or stderr against the contents of a file

func (FileMatcher) Match

func (m FileMatcher) Match(got interface{}, expected interface{}) MatcherResult

type GreaterThanOrEqualMatcher added in v3.0.1

type GreaterThanOrEqualMatcher struct {
}

GreaterThanOrEqualMatcher matches if given values are greater than

func (GreaterThanOrEqualMatcher) Match added in v3.0.1

func (m GreaterThanOrEqualMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches the values if they are greater than

type JSONMatcher

type JSONMatcher struct {
}

func (JSONMatcher) Match

func (m JSONMatcher) Match(got interface{}, expected interface{}) MatcherResult

type LessThanOrEqualMatcher added in v3.0.1

type LessThanOrEqualMatcher struct {
}

LessThanOrEqualMatcher matches if given values are less than

func (LessThanOrEqualMatcher) Match added in v3.0.1

func (m LessThanOrEqualMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches the values if they are less than

type Matcher

type Matcher interface {
	Match(actual interface{}, expected interface{}) MatcherResult
}

Matcher interface which is implemented by all matchers

func NewMatcher

func NewMatcher(matcher string) Matcher

NewMatcher creates a new matcher by type

type MatcherResult

type MatcherResult struct {
	Success bool
	Diff    string
}

MatcherResult will be returned by the executed matcher

type NotContainsMatcher

type NotContainsMatcher struct {
}

func (NotContainsMatcher) Match

func (m NotContainsMatcher) Match(got interface{}, expected interface{}) MatcherResult

type PatternMatcher added in v3.0.1

type PatternMatcher struct {
}

PatternMatcher matches if given values are equal

func (PatternMatcher) Match added in v3.0.1

func (m PatternMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches the values if they are equal

type TextMatcher

type TextMatcher struct {
}

TextMatcher matches if two texts are equals

func (TextMatcher) Match

func (m TextMatcher) Match(got interface{}, expected interface{}) MatcherResult

Match matches both texts

type XMLMatcher

type XMLMatcher struct {
}

func (XMLMatcher) Match

func (m XMLMatcher) Match(got interface{}, expected interface{}) MatcherResult

Jump to

Keyboard shortcuts

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