matchers

package
v0.0.0-...-20a187a Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONExactlyMatcher

func JSONExactlyMatcher(actual string, expected string) error

JSONExactlyMatcher checks that actual and expected JSON represents exactly the same data structure

func JSONMatcher

func JSONMatcher(actual string, expected string) error

JSONMatcher checks that actual JSON value deeply contains expected value In other words actual value should be superset of expected See tests for more examples

func RegexpMatcher

func RegexpMatcher(actual string, expected string) error

RegexpMatcher matches actual value against regular expression

func RegisterMatcher

func RegisterMatcher(name string, matcher Matcher)

RegisterMatcher registers new matcher with given name. Should be typically called in init() function.

Types

type JSONMatcherError

type JSONMatcherError struct {
	MatcherError
	// contains filtered or unexported fields
}

JSONMatcherError is MatchError with mismatch path details

func (JSONMatcherError) Error

func (jme JSONMatcherError) Error() string

type Matcher

type Matcher func(actual string, expected string) error

Matcher is function that matches two string values in some way It returns nil if arguments match or error with mismatch description otherwise

func GetMatcher

func GetMatcher(name string) (Matcher, error)

GetMatcher returns registered matcher by name

type MatcherError

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

MatcherError is an Error instance describing mismatch

func (MatcherError) Error

func (me MatcherError) Error() string

Jump to

Keyboard shortcuts

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