Documentation
¶
Index ¶
- func CreateTempDB(t *testing.T, dsn string) (string, *sql.DB)
- func DropTempDB(baseDSN, dbName string)
- func MakePullRequest(clientID string, checkpoint int64, schemaVersion int64, schemaHash string) *synchro.PullRequest
- func MakePushRecord(id, table, operation string, data map[string]any) synchro.PushRecord
- func MakePushRequest(clientID string, schemaVersion int64, schemaHash string, ...) *synchro.PushRequest
- func MakeRegisterRequest(clientID, platform, version string) *synchro.RegisterRequest
- func MustMarshal(v any) json.RawMessage
- func NewTestRegistry() *synchro.Registry
- func ReplaceDSNDatabase(dsn, newDB string) string
- func SetupTestSchema(ctx context.Context, db *sql.DB) error
- func TestDB(t *testing.T) *sql.DB
- func TestDBWithAppRole(t *testing.T) (adminDB *sql.DB, appDB *sql.DB)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTempDB ¶
CreateTempDB creates a uniquely-named database for test isolation. Returns the database name and a connection to it. The caller must call DropTempDB in cleanup.
func DropTempDB ¶
func DropTempDB(baseDSN, dbName string)
DropTempDB connects to the base DSN and drops the named database.
func MakePullRequest ¶
func MakePullRequest(clientID string, checkpoint int64, schemaVersion int64, schemaHash string) *synchro.PullRequest
MakePullRequest creates a PullRequest with schema fields for testing.
func MakePushRecord ¶
func MakePushRecord(id, table, operation string, data map[string]any) synchro.PushRecord
MakePushRecord creates a PushRecord for testing.
func MakePushRequest ¶
func MakePushRequest(clientID string, schemaVersion int64, schemaHash string, changes ...synchro.PushRecord) *synchro.PushRequest
MakePushRequest creates a PushRequest with schema fields for testing.
func MakeRegisterRequest ¶
func MakeRegisterRequest(clientID, platform, version string) *synchro.RegisterRequest
MakeRegisterRequest creates a RegisterRequest for testing.
func MustMarshal ¶
func MustMarshal(v any) json.RawMessage
MustMarshal marshals v to JSON or panics.
func NewTestRegistry ¶
NewTestRegistry creates a minimal Northwind-based registry for testing.
func ReplaceDSNDatabase ¶
ReplaceDSNDatabase returns a new DSN with the database name replaced.
func SetupTestSchema ¶
SetupTestSchema creates the application types and tables, then sets REPLICA IDENTITY FULL for WAL logical replication. Idempotent — safe to call on every startup.
func TestDB ¶
TestDB creates an isolated temporary database, runs migrations and app DDL, and returns a *sql.DB. It calls t.Skip if TEST_DATABASE_URL is not set. The temporary database is dropped on cleanup.
func TestDBWithAppRole ¶
TestDBWithAppRole creates an isolated temporary database and returns two connections: adminDB (superuser, for DDL/assertions) and appDB (non-superuser, for engine operations under RLS).
PostgreSQL superusers always bypass RLS, so RLS tests must use a non-superuser connection. The function creates the "synchro_app" role (if not exists) and grants it access to all tables in the temp database.
Types ¶
This section is empty.