internalmock

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScenarioHeader     = "x-scenario-override"
	ScenarioDisconnect = "disconnect"
	ScenarioTimeout    = "timeout"
)

Variables

This section is empty.

Functions

func EchoHandler

func EchoHandler() http.HandlerFunc

EchoHandler is a simple http handler that echos the request body back to the client if the x-scenario-override header is provided it will trigger a specific scenario

func JsonHandler

func JsonHandler[T any](handler func(r *http.Request) (T, error)) http.HandlerFunc

func NewTestRequest

func NewTestRequest() *http.Request

func NewTestRequestCloner

func NewTestRequestCloner(req *http.Request) spec.RequestCloner

func NewTestResponse

func NewTestResponse() *http.Response

func NewTestResponseCloner

func NewTestResponseCloner(res *http.Response) spec.ResponseCloner

func NewTestSerializableRequest

func NewTestSerializableRequest() *spec.SerializableRequest

func NewTestSerializableResponse

func NewTestSerializableResponse() *spec.SerializableResponse

func NewTestSnapshot

func NewTestSnapshot() *spec.Snapshot

func NewTestSnapshotRef

func NewTestSnapshotRef() *spec.SnapshotRef

Types

type MockRoundTripper

type MockRoundTripper struct {
	mock.Mock
}

func (*MockRoundTripper) RoundTrip

func (m *MockRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

type MockSnapshotMessageTopic

type MockSnapshotMessageTopic struct {
	mock.Mock
}

func (*MockSnapshotMessageTopic) Publish

func (m *MockSnapshotMessageTopic) Publish(ctx context.Context, message spec.Snapshot) (err error)

func (*MockSnapshotMessageTopic) Subscribe

func (m *MockSnapshotMessageTopic) Subscribe(ctx context.Context) (stream messaging.Stream[spec.Snapshot], err error)

type MockSnapshotRouter

type MockSnapshotRouter struct {
	mock.Mock
}

func (*MockSnapshotRouter) Match

func (m *MockSnapshotRouter) Match(req *http.Request) (ref *spec.SnapshotRef, er error)

func (*MockSnapshotRouter) Register

func (m *MockSnapshotRouter) Register(ref *spec.SnapshotRef, rules ...spec.MatchRule) spec.SnapshotRouter

type MockSnapshotStore

type MockSnapshotStore struct {
	mock.Mock
}

func (*MockSnapshotStore) Read

func (m *MockSnapshotStore) Read(ref *spec.SnapshotRef) (snapshot *spec.Snapshot, err error)

func (*MockSnapshotStore) Write

func (m *MockSnapshotStore) Write(snapshot *spec.Snapshot) (ref *spec.SnapshotRef, err error)

Jump to

Keyboard shortcuts

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