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: 16 Imported by: 0 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

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

Functions

func BuildVars added in v1.0.0

func BuildVars(
	state *types.State,
	requestRecord *types.RequestRecord,
	requestRecords []types.RequestRecord,
	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