mock

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToReadableError added in v0.1.4

func ToReadableError(validationErrors []ValidationError) string

Types

type AssertHeader

type AssertHeader map[string][]string

type AssertOptions

type AssertOptions struct {
	Route     string     `json:"route"`
	Nth       int        `json:"nth"`
	Condition *Condition `json:"condition"`
}

type AssertResponse

type AssertResponse struct {
	ValidationErrors []ValidationError `json:"validation_errors"`
}

type Condition added in v0.1.2

type Condition struct {
	Type      ConditionType          `json:"type"`
	Key       string                 `json:"key"`
	Value     ConditionValue         `json:"value"`
	KeyValues map[string]interface{} `json:"key_values"`
	And       *Condition             `json:"and"`
	Or        *Condition             `json:"or"`
}

type ConditionType added in v0.1.2

type ConditionType int
const (
	ConditionType_None ConditionType = iota
	ConditionType_HeaderMatch
	ConditionType_MethodMatch
	ConditionType_JsonBodyMatch
	ConditionType_FormMatch
	ConditionType_QuerystringMatch
	ConditionType_QuerystringMatchRegex
	ConditionType_QuerystringExactMatch
	ConditionType_QuerystringExactMatchRegex
	ConditionType_Nth
	ConditionType_RouteParamMatch
)

func (*ConditionType) MarshalJSON added in v0.1.2

func (this *ConditionType) MarshalJSON() ([]byte, error)

func (*ConditionType) UnmarshalJSON added in v0.1.2

func (this *ConditionType) UnmarshalJSON(data []byte) (err error)

type ConditionValue added in v0.8.0

type ConditionValue string

func (*ConditionValue) UnmarshalJSON added in v0.8.0

func (this *ConditionValue) UnmarshalJSON(data []byte) (err error)

type MockConfig

type MockConfig struct {
	Url string
}

func Init

func Init(url string) *MockConfig

type ValidationError

type ValidationError struct {
	Code     ValidationErrorCode `json:"code"`
	Metadata map[string]string   `json:"metadata"`
}

func Assert

func Assert(config *MockConfig, assertOptions *AssertOptions) ([]ValidationError, error)

type ValidationErrorCode

type ValidationErrorCode int
const (
	ValidationErrorCode_Unknown ValidationErrorCode = iota
	ValidationErrorCode_NoCall
	ValidationErrorCode_MethodMismatch
	ValidationErrorCode_HeaderNotIncluded
	ValidationErrorCode_HeaderValueMismatch
	ValidationErrorCode_BodyMismatch
	ValidationErrorCode_RequestHasNoBodyContent
	ValidationErrorCode_FormKeyDoesNotExist
	ValidationErrorCode_FormValueMismatch
	ValidationErrorCode_NthOutOfRange
	ValidationErrorCode_RequestHasNoQuerystring
	ValidationErrorCode_QuerystringMismatch
	ValidationErrorCode_QuerystringKeyNotSet
	ValidationErrorCode_RequestHasNoBody
	ValidationErrorCode_NthMismatch
	ValidationErrorCode_RouteParamValueMismatch
	ValidationErrorCode_RouteParamDoesNotExistInEndpoint
)

func (*ValidationErrorCode) MarshalJSON

func (this *ValidationErrorCode) MarshalJSON() ([]byte, error)

func (*ValidationErrorCode) UnmarshalJSON

func (this *ValidationErrorCode) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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