dittomock

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotMatched = errors.New("dittomock: request not matched")

Functions

This section is empty.

Types

type DittoBodyPattern

type DittoBodyPattern struct {
	EqualToJson     json.RawMessage  `json:"equalToJson,omitempty"`
	MatchesJsonPath *JSONPathWrapper `json:"matchesJsonPath,omitempty"`
}

type DittoMock

type DittoMock struct {
	Request  *DittoRequest
	Response []*DittoResponse
}

func FromProto

func FromProto(req *api.DittoMock) (DittoMock, error)

type DittoRequest

type DittoRequest struct {
	Method       string
	BodyPatterns []DittoBodyPattern `json:"bodyPatterns"`
}

func (*DittoRequest) String

func (dr *DittoRequest) String() string

type DittoResponse

type DittoResponse struct {
	Body   json.RawMessage
	Status *RpcStatus
}

type JSONPathMessage

type JSONPathMessage struct {
	Expression string `json:"expression,omitempty"`
	Contains   string `json:"contains,omitempty"`
	Equals     string `json:"eq,omitempty"`
	Regexp     string `json:"regexp,omitempty"`
}

type JSONPathWrapper

type JSONPathWrapper struct {
	JSONPathMessage
	Partial bool `json:"-"`
}

func (*JSONPathWrapper) UnmarshalJSON

func (w *JSONPathWrapper) UnmarshalJSON(data []byte) error

type RequestMatcher

type RequestMatcher struct {
	// contains filtered or unexported fields
}

func NewRequestMatcher

func NewRequestMatcher(opts ...RequestMatherOption) (*RequestMatcher, error)

func (*RequestMatcher) AddMock

func (rm *RequestMatcher) AddMock(mock DittoMock)

func (*RequestMatcher) Clear

func (rm *RequestMatcher) Clear()

func (*RequestMatcher) Match

func (rm *RequestMatcher) Match(method string, js []byte) (*DittoMock, error)

func (*RequestMatcher) Mocks added in v0.8.0

func (rm *RequestMatcher) Mocks() map[string][]DittoMock

type RequestMatherOption

type RequestMatherOption func(*RequestMatcher)

func WithLogger

func WithLogger(l logger.Logger) RequestMatherOption

func WithMocks

func WithMocks(mocks []DittoMock) RequestMatherOption

func WithMocksPath

func WithMocksPath(mocksPath string) RequestMatherOption

type RpcStatus

type RpcStatus struct {
	Code    codes.Code
	Message string
}

Jump to

Keyboard shortcuts

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