httpmocks

package
v0.6.0-beta Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockEngine

type MockEngine struct {
	InitFunc   func(context.Context) (bool, error)
	ExecFunc   func(context.Context, []byte) (bool, error)
	FlushFunc  func(context.Context, io.Writer) (int, error)
	FinishFunc func() error
}

MockEngine implements the engine.Engine interface for testing

func (*MockEngine) Exec

func (m *MockEngine) Exec(ctx context.Context, input []byte) (bool, error)

func (*MockEngine) Finish

func (m *MockEngine) Finish() error

func (*MockEngine) Flush

func (m *MockEngine) Flush(ctx context.Context, w io.Writer) (int, error)

func (*MockEngine) Init

func (m *MockEngine) Init(ctx context.Context) (bool, error)

type MockRequestHandler

type MockRequestHandler struct {
	ProcessFunc          func(handlers.RequestSession) (handlers.RequestSession, error)
	GetConfigFunc        func() engine.Config
	GetEngineFunc        func(cfg engine.Config, rs resource.Resource, pe *persist.Persister) engine.Engine
	OutputFunc           func(rs handlers.RequestSession) (handlers.RequestSession, error)
	ResetFunc            func(rs handlers.RequestSession) (handlers.RequestSession, error)
	ShutdownFunc         func()
	GetRequestParserFunc func() handlers.RequestParser
}

MockRequestHandler implements handlers.RequestHandler interface for testing

func (*MockRequestHandler) GetConfig

func (m *MockRequestHandler) GetConfig() engine.Config

func (*MockRequestHandler) GetEngine

func (*MockRequestHandler) GetRequestParser

func (m *MockRequestHandler) GetRequestParser() handlers.RequestParser

func (*MockRequestHandler) Output

func (*MockRequestHandler) Process

func (*MockRequestHandler) Reset

func (*MockRequestHandler) Shutdown

func (m *MockRequestHandler) Shutdown()

type MockRequestParser

type MockRequestParser struct {
	GetSessionIdFunc func(any) (string, error)
	GetInputFunc     func(any) ([]byte, error)
}

MockRequestParser implements the handlers.RequestParser interface for testing

func (*MockRequestParser) GetInput

func (m *MockRequestParser) GetInput(rq any) ([]byte, error)

func (*MockRequestParser) GetSessionId

func (m *MockRequestParser) GetSessionId(rq any) (string, error)

type MockWriter

type MockWriter struct {
	WriteStringCalled bool
	WrittenString     string
}

MockWriter implements a mock io.Writer for testing

func (*MockWriter) Header

func (m *MockWriter) Header() http.Header

func (*MockWriter) Write

func (m *MockWriter) Write(p []byte) (n int, err error)

func (*MockWriter) WriteHeader

func (m *MockWriter) WriteHeader(statusCode int)

func (*MockWriter) WriteString

func (m *MockWriter) WriteString(s string) (n int, err error)

Jump to

Keyboard shortcuts

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