mock

package
v1.4.16 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 (ct *ConditionType) MarshalJSON() ([]byte, error)

func (*ConditionType) UnmarshalJSON added in v0.1.2

func (ct *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 (cv *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 (vec *ValidationErrorCode) MarshalJSON() ([]byte, error)

func (*ValidationErrorCode) UnmarshalJSON

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

Jump to

Keyboard shortcuts

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