mock

package
v1.4.14 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResponseFileDoesNotExist = errors.New("ErrResponseFileDoesNotExist")

Functions

func BuildVars added in v1.0.0

func BuildVars(
	state *types.State,
	responseStatusCode int,
	requestRecord *types.RequestRecord,
	requestRecords []types.RequestRecord,
	requestBody []byte,
	baseApi string,
) (map[string]string, error)

func ExtractHeadersFromFile added in v1.4.0

func ExtractHeadersFromFile(filePath string, readFile types.ReadFileFunc) (map[string]string, error)

func ParseAssertRequest

func ParseAssertRequest(req *http.Request) (*AssertOptions, error)

func Validate

func Validate(
	mockFs types.MockFs,
	assertOptions *AssertOptions,
) (*[]ValidationError, error)

func VerifyCondition added in v1.1.0

func VerifyCondition(requestRecord *types.RequestRecord, condition *Condition, requestRecords []types.RequestRecord) bool

Types

type EndpointConfigError

type EndpointConfigError struct {
	Code          EndpointConfigErrorCode
	EndpointIndex int
	Metadata      map[string]string
}

func ValidateEndpointConfigs

func ValidateEndpointConfigs(
	endpointConfigs []types.EndpointConfig,
	readFile types.ReadFileFunc,
	configDirPath string,
) ([]EndpointConfigError, error)

type EndpointConfigErrorCode

type EndpointConfigErrorCode int
const (
	EndpointConfigErrorCode_Unknown EndpointConfigErrorCode = iota
	EndpointConfigErrorCode_EndpointDuplicate
	EndpointConfigErrorCode_FileUnreadable
	EndpointConfigErrorCode_InvalidMethod
	EndpointConfigErrorCode_RouteWithQuerystring
)

type ExecFunc added in v0.2.0

type ExecFunc = func(command string, options *ExecOptions) (*ExecResult, error)

type ExecOptions added in v1.0.0

type ExecOptions struct {
	Env        map[string]string
	WorkingDir string
}

type ExecResult added in v0.2.0

type ExecResult struct {
	Output []byte
}

type HandlerFiles added in v1.4.4

type HandlerFiles struct {
	Headers            string
	Body               string
	ResponseBody       string
	ResponseHeaders    string
	ResponseStatusCode string
}

func BuildHandlerFiles added in v1.4.4

func BuildHandlerFiles(
	requestBody []byte,
	requestRecord *types.RequestRecord,
	responseBody []byte,
	responseHeaders *http.Header,
	responseStatusCode int,
) (map[string]string, *HandlerFiles, error)

type Response

type Response struct {
	Body                []byte
	EndpointContentType types.Endpoint_content_type
	StatusCode          int
	Headers             map[string]string
}

func ResolveEndpointResponse

func ResolveEndpointResponse(
	readFile types.ReadFileFunc,
	exec ExecFunc,
	requestBody []byte,
	state *types.State,
	endpointConfig *types.EndpointConfig,
	envVars map[string]string,
	endpointParams map[string]string,
	requestRecord *types.RequestRecord,
	requestRecords []types.RequestRecord,
	baseApi string,
	cache map[string]string,
) (*Response, map[string]string, error)

Jump to

Keyboard shortcuts

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