matcher

package
v2.10.24 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package matcher for matching utilities

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHTTPBodyToMap

func AddHTTPBodyToMap(body string, m map[string][]string) error

func ArrayToMap

func ArrayToMap(arr []string) map[string]bool

func CompareHeaders

func CompareHeaders(h1 http.Header, h2 http.Header, res *[]models.HeaderResult, noise map[string][]string) bool

func CompareResponses

func CompareResponses(response1, response2 *interface{}, key string)

CompareResponses compares response1 (expected) and response2 (actual), updating utils.TemplatizedValues and mutating response1 where appropriate.

func Contains

func Contains(elems []string, v string) bool

func FindOperation

func FindOperation(item models.PathItem) (*models.Operation, string)

func Flatten

func Flatten(j interface{}) map[string][]string

Flatten takes a map and returns a new one where nested maps are replaced by dot-delimited keys. examples of valid jsons - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#examples

func InterfaceToString

func InterfaceToString(val interface{}) string

func JsonContains added in v2.5.3

func JsonContains(actualJSON string, expectedJSON map[string]interface{}) (bool, error)

func MapToArray

func MapToArray(mp map[string][]string) []string

func MarshalRequestBodies

func MarshalRequestBodies(mockOperation, testOperation *models.Operation) (string, string, error)

func MarshalResponseBodies

func MarshalResponseBodies(status string, mockOperation, testOperation *models.Operation) (string, string, error)

func MatchesAnyRegex

func MatchesAnyRegex(str string, regexArray []string) (bool, string)

func ParseIntoJSON

func ParseIntoJSON(response string) (interface{}, error)

ParseIntoJSON Parse the json string into a geko type variable, it will maintain the order of the keys in the json.

func SubstringKeyMatch added in v2.6.21

func SubstringKeyMatch(s string, mp map[string][]string) ([]string, bool)

func UnmarshallJSON

func UnmarshallJSON(s string, log *zap.Logger) (interface{}, error)

UnmarshallJSON returns unmarshalled JSON object.

Types

type DiffsPrinter

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

func NewDiffsPrinter

func NewDiffsPrinter(testCase string) DiffsPrinter

func (*DiffsPrinter) PushBodyDiff

func (d *DiffsPrinter) PushBodyDiff(exp, act string, noise map[string][]string)

func (*DiffsPrinter) PushFooterDiff

func (d *DiffsPrinter) PushFooterDiff(key string)

func (*DiffsPrinter) PushHeaderDiff

func (d *DiffsPrinter) PushHeaderDiff(exp, act, key string, noise map[string][]string)

func (*DiffsPrinter) PushStatusDiff

func (d *DiffsPrinter) PushStatusDiff(exp, act string)

func (*DiffsPrinter) PushTypeDiff

func (d *DiffsPrinter) PushTypeDiff(exp, act string)

func (*DiffsPrinter) Render

func (d *DiffsPrinter) Render() error

Render will display and colorize diffs side-by-side

func (*DiffsPrinter) RenderAppender

func (d *DiffsPrinter) RenderAppender() error

func (*DiffsPrinter) SetHasarrayIndexMismatch

func (d *DiffsPrinter) SetHasarrayIndexMismatch(has bool)

func (*DiffsPrinter) TableWriter

func (d *DiffsPrinter) TableWriter(diffs []string) error

type JSONComparisonResult

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

func JSONDiffWithNoiseControl

func JSONDiffWithNoiseControl(validatedJSON ValidatedJSON, noise map[string][]string, ignoreOrdering bool) (JSONComparisonResult, error)

func (*JSONComparisonResult) Differences

func (v *JSONComparisonResult) Differences() []string

func (*JSONComparisonResult) IsExact

func (v *JSONComparisonResult) IsExact() bool

func (*JSONComparisonResult) Matches

func (v *JSONComparisonResult) Matches() bool

type ValidatedJSON

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

func ValidateAndMarshalJSON

func ValidateAndMarshalJSON(log *zap.Logger, exp, act *string) (ValidatedJSON, error)

func (*ValidatedJSON) Actual

func (v *ValidatedJSON) Actual() interface{}

func (*ValidatedJSON) Expected

func (v *ValidatedJSON) Expected() interface{}

func (*ValidatedJSON) IsIdentical

func (v *ValidatedJSON) IsIdentical() bool

Directories

Path Synopsis
Package grpc provides gRPC response matching functionality
Package grpc provides gRPC response matching functionality
Package http for http matching
Package http for http matching
Package schema for schema matching
Package schema for schema matching

Jump to

Keyboard shortcuts

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