Documentation
¶
Overview ¶
Package testing provides a mock implementation of the tarantool.Doer and other interfaces. It is used for testing purposes.
Index ¶
- type DummyT
- func (t *DummyT) Attr(_, _ string)
- func (t *DummyT) Chdir(_ string)
- func (t *DummyT) Cleanup(f func())
- func (t *DummyT) Cleanups()
- func (t *DummyT) Error(_ ...any)
- func (t *DummyT) Errorf(format string, args ...any)
- func (t *DummyT) Fail()
- func (t *DummyT) FailNow()
- func (t *DummyT) Failed() bool
- func (t *DummyT) Fatal(args ...any)
- func (t *DummyT) Fatalf(format string, args ...any)
- func (t *DummyT) Helper()
- func (t *DummyT) Log(args ...any)
- func (t *DummyT) Logf(format string, args ...any)
- func (t *DummyT) Name() string
- func (t *DummyT) Setenv(_, _ string)
- func (t *DummyT) Skip(_ ...any)
- func (t *DummyT) SkipNow()
- func (t *DummyT) Skipf(format string, args ...any)
- func (t *DummyT) Skipped() bool
- type MockDoer
- type MockDoerWithWatcher
- type MockRequest
- func (req *MockRequest) Async() bool
- func (req *MockRequest) Body(_ tarantool.SchemaResolver, _ *msgpack.Encoder) error
- func (req *MockRequest) Conn() *tarantool.Connection
- func (req *MockRequest) Ctx() context.Context
- func (req *MockRequest) Response(header tarantool.Header, body io.Reader) (tarantool.Response, error)
- func (req *MockRequest) Type() iproto.Type
- type MockResponse
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DummyT ¶
DummyT is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Chdir ¶
Chdir is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Cleanup ¶
func (t *DummyT) Cleanup(f func())
Cleanup is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Cleanups ¶
func (t *DummyT) Cleanups()
Cleanups should be called to call all cleanup functions on "test" exit.
func (*DummyT) Error ¶
Error is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Errorf ¶
Errorf is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Fail ¶
func (t *DummyT) Fail()
Fail is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) FailNow ¶
func (t *DummyT) FailNow()
FailNow is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Failed ¶
Failed is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Fatal ¶
Fatal is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Fatalf ¶
Fatalf is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Helper ¶
func (t *DummyT) Helper()
Helper is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) Setenv ¶
Setenv is a dummy implementation of the testing.T interface to use in examples.
func (*DummyT) SkipNow ¶
func (t *DummyT) SkipNow()
SkipNow is a dummy implementation of the testing.T interface to use in examples.
type MockDoer ¶
type MockDoer struct {
// Requests is a slice of received requests.
// It could be used to compare incoming requests with expected.
Requests []tarantool.Request
// contains filtered or unexported fields
}
MockDoer is an implementation of the Doer interface used for testing purposes.
func NewMockDoer ¶
NewMockDoer creates a MockDoer by given responses. Each response could be one of two types: MockResponse or error.
type MockDoerWithWatcher ¶
type MockDoerWithWatcher struct {
// contains filtered or unexported fields
}
MockDoerWithWatcher is a mock implementation of the tarantool.DoerWithWatcher interface.
func NewMockDoerWithWatcher ¶
func NewMockDoerWithWatcher(doer *MockDoer, events map[string][]tarantool.WatchEvent) *MockDoerWithWatcher
NewMockDoerWithWatcher returns a new mock doer with watcher.
func (*MockDoerWithWatcher) Do ¶
func (m *MockDoerWithWatcher) Do(req tarantool.Request) *tarantool.Future
Do returns a new future.
func (*MockDoerWithWatcher) NewWatcher ¶
func (m *MockDoerWithWatcher) NewWatcher(path string, callback tarantool.WatchCallback) (tarantool.Watcher, error)
NewWatcher returns a new watcher.
type MockRequest ¶
type MockRequest struct {
}
MockRequest is an empty mock request used for testing purposes.
func NewMockRequest ¶
func NewMockRequest() *MockRequest
NewMockRequest creates an empty MockRequest.
func (*MockRequest) Async ¶
func (req *MockRequest) Async() bool
Async returns if MockRequest expects a response.
func (*MockRequest) Body ¶
func (req *MockRequest) Body(_ tarantool.SchemaResolver, _ *msgpack.Encoder) error
Body fills an msgpack.Encoder with the watch request body.
func (*MockRequest) Conn ¶
func (req *MockRequest) Conn() *tarantool.Connection
Conn returns the Connection object the request belongs to.
func (*MockRequest) Ctx ¶
func (req *MockRequest) Ctx() context.Context
Ctx returns a context of the MockRequest.
func (*MockRequest) Response ¶
func (req *MockRequest) Response( header tarantool.Header, body io.Reader, ) (tarantool.Response, error)
Response creates a response for the MockRequest.
func (*MockRequest) Type ¶
func (req *MockRequest) Type() iproto.Type
Type returns an iproto type for MockRequest.
type MockResponse ¶
type MockResponse struct {
// contains filtered or unexported fields
}
MockResponse is a mock response used for testing purposes.
func CreateMockResponse ¶
func CreateMockResponse(header tarantool.Header, body io.Reader) (*MockResponse, error)
CreateMockResponse creates a MockResponse from the header and a data, packed inside an io.Reader.
func NewMockResponse ¶
func NewMockResponse(t T, body any) *MockResponse
NewMockResponse creates a new MockResponse with an empty header and the given data. body should be passed as a structure to be encoded. The encoded body is served as response data and will be decoded once the response is decoded.
func (*MockResponse) Decode ¶
func (resp *MockResponse) Decode() ([]any, error)
Decode returns the result of decoding the response data as slice.
func (*MockResponse) DecodeTyped ¶
func (resp *MockResponse) DecodeTyped(res any) error
DecodeTyped returns the result of decoding the response data.
func (*MockResponse) Header ¶
func (resp *MockResponse) Header() tarantool.Header
Header returns a header for the MockResponse.