matcher

package
v2.3.0-beta18 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package matcher for matching utilities

Index

Constants

View Source
const MAX_LINE_LENGTH = 50

MAX_LINE_LENGTH is chars PER expected/actual string. Can be changed no problem

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 CheckStringExist

func CheckStringExist(s string, mp map[string][]string) ([]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 the two responses, if there is any difference in the values, It checks in the templatized values map if the value is already present, it will update the value in the map. It also changes the expected value to the actual value in the response1 (expected body)

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 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 ToString

func ToString(val interface{}) string

ToString remove all types of value to strings for comparison.

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 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