Documentation
¶
Overview ¶
Package apitest provides test doubles for the powersync/api package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMockClientFactory ¶
func NewMockClientFactory(mock *MockClient) func(endpoint string) api.Client
NewMockClientFactory returns a client factory that always returns the given mock.
Types ¶
type MockClient ¶
type MockClient struct {
// SyncStreamFunc is called when SyncStream is invoked.
SyncStreamFunc func(ctx context.Context, req *api.SyncStreamRequest, handler api.LineHandler) error
// GetWriteCheckpointFunc is called when GetWriteCheckpoint is invoked.
GetWriteCheckpointFunc func(ctx context.Context, clientID string) (string, error)
// Token is the current token set via SetToken.
Token string
// SyncStreamCalls records the number of times SyncStream was called.
SyncStreamCalls int
// GetWriteCheckpointCalls records the number of times GetWriteCheckpoint was called.
GetWriteCheckpointCalls int
}
MockClient is a test double for api.Client.
func NewMockClient ¶
func NewMockClient() *MockClient
NewMockClient creates a new MockClient with sensible defaults.
func (*MockClient) GetWriteCheckpoint ¶
GetWriteCheckpoint implements api.Client.
func (*MockClient) SetToken ¶
func (m *MockClient) SetToken(token string)
SetToken implements api.Client.
func (*MockClient) SyncStream ¶
func (m *MockClient) SyncStream(ctx context.Context, req *api.SyncStreamRequest, handler api.LineHandler) error
SyncStream implements api.Client.
Click to show internal directories.
Click to hide internal directories.