helpers

package
v0.0.0-...-7bd6b6b Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package helpers provides test utilities and helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertChangeEqual

func AssertChangeEqual(t *testing.T, expected, actual types.Change)

AssertChangeEqual compares two changes for equality.

func AssertChangeSliceEqual

func AssertChangeSliceEqual(t *testing.T, expected, actual []types.Change)

AssertChangeSliceEqual compares two slices of changes.

func AssertContainsChange

func AssertContainsChange(t *testing.T, changes []types.Change, serverName string, changeType types.ChangeType)

AssertContainsChange asserts that a slice contains a change with the given server name.

func AssertDiffResultEqual

func AssertDiffResultEqual(t *testing.T, expected, actual *types.DiffResult)

AssertDiffResultEqual compares two diff results.

func AssertEventuallyTrue

func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, msg string)

AssertEventuallyTrue asserts that a condition becomes true within timeout.

func AssertFiltersEqual

func AssertFiltersEqual(t *testing.T, expected, actual types.SubscriptionFilter)

AssertFiltersEqual compares two subscription filters.

func AssertNotContainsChange

func AssertNotContainsChange(t *testing.T, changes []types.Change, serverName string)

AssertNotContainsChange asserts that a slice does not contain a change with the given server name.

func AssertNotificationSent

func AssertNotificationSent(t *testing.T, notification types.Notification)

AssertNotificationSent asserts that a notification was sent correctly.

func AssertServerEqual

func AssertServerEqual(t *testing.T, expected, actual types.Server)

AssertServerEqual compares two servers for equality.

func AssertSnapshotEqual

func AssertSnapshotEqual(t *testing.T, expected, actual *types.Snapshot)

AssertSnapshotEqual compares two snapshots.

func AssertSubscriptionEqual

func AssertSubscriptionEqual(t *testing.T, expected, actual types.Subscription)

AssertSubscriptionEqual compares two subscriptions for equality.

func AssertWithinDuration

func AssertWithinDuration(t *testing.T, expected, actual time.Time, delta time.Duration)

AssertWithinDuration asserts that a time is within a duration of now.

func RunMigrations

func RunMigrations(dbURL string, migrationsPath string) error

RunMigrations executes SQL migration files.

func SetupFullTestEnvironment

func SetupFullTestEnvironment(t *testing.T) (*TestDB, *TestCache, func())

SetupFullTestEnvironment creates both database and cache for testing.

Types

type PostgresContainer

type PostgresContainer struct {
	Container testcontainers.Container
	URL       string
}

PostgresContainer wraps a test PostgreSQL container.

func StartPostgres

func StartPostgres(t *testing.T) (*PostgresContainer, func())

StartPostgres starts a PostgreSQL test container.

func StartPostgresWithMigrations

func StartPostgresWithMigrations(t *testing.T, migrationsPath string) (*PostgresContainer, func())

StartPostgresWithMigrations starts PostgreSQL and runs migrations.

type RedisContainer

type RedisContainer struct {
	Container testcontainers.Container
	URL       string
}

RedisContainer wraps a test Redis container.

func StartRedis

func StartRedis(t *testing.T) (*RedisContainer, func())

StartRedis starts a Redis test container.

type TestCache

type TestCache struct {
	Cache db.Cache
	URL   string
	// contains filtered or unexported fields
}

TestCache provides cache helpers for testing.

func SetupTestCache

func SetupTestCache(t *testing.T) *TestCache

SetupTestCache creates a new test Redis cache.

func (*TestCache) FlushAll

func (tc *TestCache) FlushAll(t *testing.T)

FlushAll clears all data from the cache. Note: The Cache interface doesn't expose FlushAll, so we use Delete with a pattern.

func (*TestCache) Teardown

func (tc *TestCache) Teardown(t *testing.T)

TeardownTestCache cleans up the test cache.

type TestDB

type TestDB struct {
	Database db.Database
	URL      string
	// contains filtered or unexported fields
}

TestDB provides database helpers for testing.

func SetupTestDB

func SetupTestDB(t *testing.T) *TestDB

SetupTestDB creates a new test database with migrations applied.

func (*TestDB) ClearTables

func (tdb *TestDB) ClearTables(t *testing.T)

ClearTables clears all data from the database tables. Note: This is a no-op since the Database interface doesn't expose raw Exec. For proper test isolation, recreate the container between tests.

func (*TestDB) Teardown

func (tdb *TestDB) Teardown(t *testing.T)

TeardownTestDB cleans up the test database.

Jump to

Keyboard shortcuts

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