mock

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func ParseAssertRequest

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

func Validate

func Validate(
	mockFs types.MockFs,
	assertConfig *AssertConfig,
) (*[]ValidationError, error)

Types

type EndpointConfigError

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

func ValidateEndpointConfigs

func ValidateEndpointConfigs(
	endpointConfigs []types.EndpointConfig,
	readFile 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, env map[string]string) (*ExecResult, error)

type ExecResult added in v0.2.0

type ExecResult struct {
	Output []byte
}

type ReadFileFunc

type ReadFileFunc = func(name string) ([]byte, error)

type Response

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

func ResolveEndpointResponse

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

Jump to

Keyboard shortcuts

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