matcher

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package matcher provides a way to match a test against a pattern.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyCondition

type BodyCondition struct {
	ID        *string        `yaml:"id"`
	Extractor *DataExtractor `yaml:"extractor"`
}

BodyCondition represents the body condition

func (BodyCondition) MatcherGenerate

func (bc BodyCondition) MatcherGenerate(ctx context.Context, log logger.Logger) (BodyConditionMatcher, error)

MatcherGenerate generates the body matcher

type BodyConditionMatcher

type BodyConditionMatcher func(body any) (bool, error)

BodyConditionMatcher represents the body matcher

type BodyConditions

type BodyConditions []BodyCondition

BodyConditions represents a slice of BodyCondition

func (BodyConditions) MatcherGenerate

func (bcs BodyConditions) MatcherGenerate(ctx context.Context, log logger.Logger) (BodyConditionsMatcher, error)

MatcherGenerate generates the body matcher

type BodyConditionsMatcher

type BodyConditionsMatcher func(body any) (string, bool, error)

BodyConditionsMatcher represents the body matcher

type CountCondition

type CountCondition struct {
	ID    *string `yaml:"id"`
	Op    *string `yaml:"op"`
	Value *any    `yaml:"value"`
}

CountCondition represents the status code condition

func (CountCondition) MatcherGenerate

func (scc CountCondition) MatcherGenerate(ctx context.Context, log logger.Logger) (CountConditionMatcher, error)

MatcherGenerate generates the status code matcher

type CountConditionMatcher

type CountConditionMatcher func(count int) bool

CountConditionMatcher represents the status code matcher

type CountConditions

type CountConditions []CountCondition

CountConditions represents the status code conditions

func (CountConditions) MatcherGenerate

func (sccs CountConditions) MatcherGenerate(ctx context.Context, log logger.Logger) (CountConditionsMatcher, error)

MatcherGenerate generates the status code conditions matcher

type CountConditionsMatcher

type CountConditionsMatcher func(count int) (string, bool)

CountConditionsMatcher represents the status code conditions matcher

type CountOperator

type CountOperator string

CountOperator represents the status code operator

const (
	// CountOperatorNone represents the none operator
	CountOperatorNone CountOperator = "none"
	// CountOperatorEqual represents the equal operator
	CountOperatorEqual CountOperator = "eq"
	// CountOperatorNotEqual represents the not equal operator
	CountOperatorNotEqual CountOperator = "ne"
	// CountOperatorLessThan represents the less than operator
	CountOperatorLessThan CountOperator = "lt"
	// CountOperatorLessEqual represents the less equal operator
	CountOperatorLessEqual CountOperator = "le"
	// CountOperatorGreaterThan represents the greater than operator
	CountOperatorGreaterThan CountOperator = "gt"
	// CountOperatorGreaterEqual represents the greater equal operator
	CountOperatorGreaterEqual CountOperator = "ge"
	// CountOperatorIn represents the in operator
	CountOperatorIn CountOperator = "in"
	// CountOperatorNotIn represents the not in operator
	CountOperatorNotIn CountOperator = "nin"
	// CountOperatorBetween represents the between operator
	CountOperatorBetween CountOperator = "between"
	// CountOperatorNotBetween represents the not between operator
	CountOperatorNotBetween CountOperator = "notBetween"
	// CountOperatorMod represents the mod operator
	CountOperatorMod CountOperator = "mod"
	// CountOperatorNotMod represents the not mod operator
	CountOperatorNotMod CountOperator = "notMod"
	// CountOperatorRegex represents the regex operator
	CountOperatorRegex CountOperator = "regex"
)

type DataExtractor

type DataExtractor struct {
	Type     *string `yaml:"type"`
	JMESPath *string `yaml:"jmes_path"`
	OnNil    *string `yaml:"on_nil"`
}

DataExtractor represents the data extractor for the OneExec runner

func (DataExtractor) Validate

func (d DataExtractor) Validate() (ValidDataExtractor, error)

Validate validates the data extractor

type DataExtractorOnNilType

type DataExtractorOnNilType string

DataExtractorOnNilType represents the on nil type for the data extractor

const (
	// DataExtractorOnNilTypeEmpty represents the empty on nil type for the data extractor
	DataExtractorOnNilTypeEmpty DataExtractorOnNilType = "empty"
	// DataExtractorOnNilTypeNull represents the null on nil type for the data extractor
	DataExtractorOnNilTypeNull DataExtractorOnNilType = "null"
	// DataExtractorOnNilTypeError represents the error on nil type for the data extractor
	DataExtractorOnNilTypeError DataExtractorOnNilType = "error"

	// DefaultDataExtractorOnNilType represents the default on nil type for the data extractor
	DefaultDataExtractorOnNilType DataExtractorOnNilType = DataExtractorOnNilTypeNull
)

type DataExtractorType

type DataExtractorType string

DataExtractorType represents the type for the data extractor

const (
	// DataExtractorTypeJMESPath represents the JMESPath type for the data extractor
	DataExtractorTypeJMESPath DataExtractorType = "jmesPath"
)

type StatusCodeCondition

type StatusCodeCondition struct {
	ID    *string `yaml:"id"`
	Op    *string `yaml:"op"`
	Value *any    `yaml:"value"`
}

StatusCodeCondition represents the status code condition

func (StatusCodeCondition) MatcherGenerate

func (scc StatusCodeCondition) MatcherGenerate(
	ctx context.Context,
	log logger.Logger,
) (StatusCodeConditionMatcher, error)

MatcherGenerate generates the status code matcher

type StatusCodeConditionMatcher

type StatusCodeConditionMatcher func(statusCode int) bool

StatusCodeConditionMatcher represents the status code matcher

type StatusCodeConditions

type StatusCodeConditions []StatusCodeCondition

StatusCodeConditions represents the status code conditions

func (StatusCodeConditions) MatcherGenerate

func (sccs StatusCodeConditions) MatcherGenerate(
	ctx context.Context,
	log logger.Logger,
) (StatusCodeConditionsMatcher, error)

MatcherGenerate generates the status code conditions matcher

type StatusCodeConditionsMatcher

type StatusCodeConditionsMatcher func(statusCode int) (string, bool)

StatusCodeConditionsMatcher represents the status code conditions matcher

type StatusCodeOperator

type StatusCodeOperator string

StatusCodeOperator represents the status code operator

const (
	// StatusCodeOperatorNone represents the none operator
	StatusCodeOperatorNone StatusCodeOperator = "none"
	// StatusCodeOperatorEqual represents the equal operator
	StatusCodeOperatorEqual StatusCodeOperator = "eq"
	// StatusCodeOperatorNotEqual represents the not equal operator
	StatusCodeOperatorNotEqual StatusCodeOperator = "ne"
	// StatusCodeOperatorLessThan represents the less than operator
	StatusCodeOperatorLessThan StatusCodeOperator = "lt"
	// StatusCodeOperatorLessEqual represents the less equal operator
	StatusCodeOperatorLessEqual StatusCodeOperator = "le"
	// StatusCodeOperatorGreaterThan represents the greater than operator
	StatusCodeOperatorGreaterThan StatusCodeOperator = "gt"
	// StatusCodeOperatorGreaterEqual represents the greater equal operator
	StatusCodeOperatorGreaterEqual StatusCodeOperator = "ge"
	// StatusCodeOperatorIn represents the in operator
	StatusCodeOperatorIn StatusCodeOperator = "in"
	// StatusCodeOperatorNotIn represents the not in operator
	StatusCodeOperatorNotIn StatusCodeOperator = "nin"
	// StatusCodeOperatorBetween represents the between operator
	StatusCodeOperatorBetween StatusCodeOperator = "between"
	// StatusCodeOperatorNotBetween represents the not between operator
	StatusCodeOperatorNotBetween StatusCodeOperator = "notBetween"
	// StatusCodeOperatorRegex represents the regex operator
	StatusCodeOperatorRegex StatusCodeOperator = "regex"
)

type TerminateType

type TerminateType string

TerminateType represents the type of terminate

const (
	// TerminateTypeByContext represents the context type
	TerminateTypeByContext TerminateType = "context"
	// TerminateTypeByCount represents the count type
	TerminateTypeByCount TerminateType = "count"
	// TerminateTypeBySystemError represents the system error type
	TerminateTypeBySystemError TerminateType = "sysError"
	// TerminateTypeByCreateRequestError represents the create request error type
	TerminateTypeByCreateRequestError TerminateType = "createRequestError"
	// TerminateTypeByParseResponseError represents the parse response error type
	TerminateTypeByParseResponseError TerminateType = "parseError"
	// TerminateTypeByWriteError represents the write error type
	TerminateTypeByWriteError TerminateType = "writeError"
	// TerminateTypeByResponseBodyWriteFilterError represents the response body filter error type
	TerminateTypeByResponseBodyWriteFilterError TerminateType = "responseBodyWriteFilterError"
	// TerminateTypeByResponseBodyDataExtractorError represents the response body extractor error type
	TerminateTypeByResponseBodyDataExtractorError TerminateType = "responseBodyDataExtractorError"
	// TerminateTypeByResponseBodyBreakFilterError represents the response body break filter error type
	TerminateTypeByResponseBodyBreakFilterError TerminateType = "responseBodyBreakFilterError"
	// TerminateTypeByTimeout represents the timeout type
	TerminateTypeByTimeout TerminateType = "time"
	// TerminateTypeByResponseBody represents the response body type
	TerminateTypeByResponseBody TerminateType = "responseBody"
	// TerminateTypeByStatusCode represents the status code type
	TerminateTypeByStatusCode TerminateType = "statusCode"
)

func (TerminateType) String

func (t TerminateType) String() string

String returns the string representation of the terminate type

type TerminateTypeAndParams

type TerminateTypeAndParams struct {
	Type   TerminateType
	Params []string
}

TerminateTypeAndParams represents the terminate type and params

func NewTerminateTypeAndParams

func NewTerminateTypeAndParams(t TerminateType, p []string) TerminateTypeAndParams

NewTerminateTypeAndParams creates a new TerminateTypeAndParams

func NewTerminateTypeFromString

func NewTerminateTypeFromString(s string) (TerminateTypeAndParams, error)

NewTerminateTypeFromString creates a new TerminateTypeAndParams from a string

func (TerminateTypeAndParams) Match

func (t TerminateTypeAndParams) Match(terminateType TerminateType, terminateParams string) bool

Match returns true if the terminate type matches the terminate type and params

type TerminateTypeAndParamsSlice

type TerminateTypeAndParamsSlice []TerminateTypeAndParams

TerminateTypeAndParamsSlice represents the slice of TerminateTypeAndParams

func NewTerminateTypeAndParamsSliceFromStringSlice

func NewTerminateTypeAndParamsSliceFromStringSlice(s []string) (TerminateTypeAndParamsSlice, error)

NewTerminateTypeAndParamsSliceFromStringSlice creates a new TerminateTypeAndParams from a string

func (TerminateTypeAndParamsSlice) Match

func (t TerminateTypeAndParamsSlice) Match(terminateType TerminateType, terminateParam string) bool

Match returns true if the terminate type and params slice matches the terminate type and params

type ValidDataExtractor

type ValidDataExtractor struct {
	Type     DataExtractorType
	JMESPath *jmespath.JMESPath
	OnNil    DataExtractorOnNilType
}

ValidDataExtractor represents the valid data extractor for the OneExec runner

func (ValidDataExtractor) Extract

func (d ValidDataExtractor) Extract(data any) (any, error)

Extract extracts the data from the response

Jump to

Keyboard shortcuts

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