powersynctest

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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) Start

func (m *MockSyncer) Start(ctx context.Context, db sqlite.DB, accountID string, onFirstSync func()) error

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.

Jump to

Keyboard shortcuts

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