Documentation
¶
Overview ¶
Package powersynctest provides test utilities for the powersync package.
For database test helpers, use powersync/db/dbtest. For mock API clients, use powersync/api/apitest.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSyncerWithMockClient ¶
func NewSyncerWithMockClient(endpoint string, tokenRefresher powersync.TokenRefresher, mock *apitest.MockClient) powersync.Syncer
NewSyncerWithMockClient creates a Syncer with a mock client for testing.
Types ¶
type MockSyncer ¶
type MockSyncer struct {
StartFunc func(ctx context.Context, db sqlite.DB, accountID string, onFirstSync func()) error
StopFunc func()
StateFunc func() powersync.State
IsReadyFunc func() bool
}
MockSyncer is a test double for powersync.Syncer.
func NewMockSyncer ¶
func NewMockSyncer() *MockSyncer
NewMockSyncer creates a MockSyncer with sensible defaults.
func (*MockSyncer) IsReady ¶
func (m *MockSyncer) IsReady() bool
func (*MockSyncer) State ¶
func (m *MockSyncer) State() powersync.State
func (*MockSyncer) Stop ¶
func (m *MockSyncer) Stop()
type MockTokenRefresher ¶
type MockTokenRefresher struct {
// GetAccessTokenFunc is called when GetAccessToken is invoked.
GetAccessTokenFunc func(ctx context.Context) (string, error)
// Calls records the number of times GetAccessToken was called.
Calls int
}
MockTokenRefresher is a test double for powersync.TokenRefresher.
func NewMockTokenRefresher ¶
func NewMockTokenRefresher(token string) *MockTokenRefresher
NewMockTokenRefresher creates a MockTokenRefresher that returns the given token.
func (*MockTokenRefresher) GetAccessToken ¶
func (m *MockTokenRefresher) GetAccessToken(ctx context.Context) (string, error)
GetAccessToken implements powersync.TokenRefresher.
Click to show internal directories.
Click to hide internal directories.