matcher

package
v0.0.0-...-8eaeb25 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertArrayFieldsToMatchers

func ConvertArrayFieldsToMatchers[T any, M any](builder MatcherBuilder[T, M], arrayValue []any) (err error)

func ConvertMapKeysToMatchers

func ConvertMapKeysToMatchers[T any, M any](builder MatcherBuilder[T, M], mapValue map[string]any) (err error)

Types

type CookieMatcher

type CookieMatcher struct {
	expectation.CueMatcher[expectation.Cookie]
}

func NewCookieMatcher

func NewCookieMatcher(value expectation.Cookie, matchType string) *CookieMatcher

func (CookieMatcher) Matches

func (m CookieMatcher) Matches(cookie *http.Cookie) bool

type CookieMatcherBuilder

type CookieMatcherBuilder struct{}

func (CookieMatcherBuilder) Create

func (CookieMatcherBuilder) CreateFromArrayValue

func (b CookieMatcherBuilder) CreateFromArrayValue(value []any, matchExpr string) (Matcher[expectation.Cookie, http.Cookie], error)

func (CookieMatcherBuilder) CreateFromSingleValue

func (b CookieMatcherBuilder) CreateFromSingleValue(value any, matchExpr string) (Matcher[expectation.Cookie, http.Cookie], error)

type Matcher

type Matcher[T any, M any] interface {
	Matches(value *M) bool
	GetValue() *T
}

TODO: consider merging this package with the expectation package as expectation package cannot use matcher as it causes a circular dependency

type MatcherBuilder

type MatcherBuilder[T any, M any] interface {
	Create(field map[string]any) (Matcher[T, M], error)
	CreateFromArrayValue(value []any, matchExpr string) (Matcher[T, M], error)
	CreateFromSingleValue(value any, matchExpr string) (Matcher[T, M], error)
}

type RequestMatcher

type RequestMatcher struct {
	Value                   expectation.Request
	RequestParameterMatcher *RequestParameterMatcher
}

func NewRequestMatcher

func NewRequestMatcher(value expectation.Request) *RequestMatcher

func (RequestMatcher) Matches

func (rm RequestMatcher) Matches(request *http.Request, requestParameters *schema.RequestParameters) bool

type RequestParameterMatcher

type RequestParameterMatcher struct {
	expectation.CueMatcher[expectation.RequestParameters]
}

func (*RequestParameterMatcher) Matches

type StringArrayMatcher

type StringArrayMatcher struct {
	expectation.CueMatcher[[]string]
}

func NewStringArrayMatcher

func NewStringArrayMatcher(value *[]string, matchType string) *StringArrayMatcher

func (StringArrayMatcher) Matches

func (m StringArrayMatcher) Matches(value *[]string) bool

type StringArrayMatcherBuilder

type StringArrayMatcherBuilder struct{}

func (StringArrayMatcherBuilder) Create

func (b StringArrayMatcherBuilder) Create(field map[string]any) (Matcher[[]string, []string], error)

func (StringArrayMatcherBuilder) CreateFromArrayValue

func (b StringArrayMatcherBuilder) CreateFromArrayValue(value []any, matchExpr string) (Matcher[[]string, []string], error)

func (StringArrayMatcherBuilder) CreateFromSingleValue

func (b StringArrayMatcherBuilder) CreateFromSingleValue(value any, matchExpr string) (Matcher[[]string, []string], error)

type StringMatcher

type StringMatcher struct {
	expectation.CueMatcher[string]
}

func NewStringMatcher

func NewStringMatcher(value *string, matchType string) *StringMatcher

func (StringMatcher) Matches

func (m StringMatcher) Matches(value *string) bool

type StringMatcherBuilder

type StringMatcherBuilder struct{}

func (StringMatcherBuilder) Create

func (b StringMatcherBuilder) Create(field map[string]any) (Matcher[string, string], error)

func (StringMatcherBuilder) CreateFromArrayValue

func (b StringMatcherBuilder) CreateFromArrayValue(value []any, matchExpr string) (Matcher[string, string], error)

func (StringMatcherBuilder) CreateFromSingleValue

func (b StringMatcherBuilder) CreateFromSingleValue(value any, matchExpr string) (Matcher[string, string], error)

Jump to

Keyboard shortcuts

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