Documentation
¶
Overview ¶
Package helpers provides test utilities and helper functions.
Index ¶
- func AssertChangeEqual(t *testing.T, expected, actual types.Change)
- func AssertChangeSliceEqual(t *testing.T, expected, actual []types.Change)
- func AssertContainsChange(t *testing.T, changes []types.Change, serverName string, ...)
- func AssertDiffResultEqual(t *testing.T, expected, actual *types.DiffResult)
- func AssertEventuallyTrue(t *testing.T, condition func() bool, timeout time.Duration, msg string)
- func AssertFiltersEqual(t *testing.T, expected, actual types.SubscriptionFilter)
- func AssertNotContainsChange(t *testing.T, changes []types.Change, serverName string)
- func AssertNotificationSent(t *testing.T, notification types.Notification)
- func AssertServerEqual(t *testing.T, expected, actual types.Server)
- func AssertSnapshotEqual(t *testing.T, expected, actual *types.Snapshot)
- func AssertSubscriptionEqual(t *testing.T, expected, actual types.Subscription)
- func AssertWithinDuration(t *testing.T, expected, actual time.Time, delta time.Duration)
- func RunMigrations(dbURL string, migrationsPath string) error
- func SetupFullTestEnvironment(t *testing.T) (*TestDB, *TestCache, func())
- type PostgresContainer
- type RedisContainer
- type TestCache
- type TestDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertChangeEqual ¶
AssertChangeEqual compares two changes for equality.
func AssertChangeSliceEqual ¶
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 ¶
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 ¶
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 ¶
AssertServerEqual compares two servers for equality.
func AssertSnapshotEqual ¶
AssertSnapshotEqual compares two snapshots.
func AssertSubscriptionEqual ¶
func AssertSubscriptionEqual(t *testing.T, expected, actual types.Subscription)
AssertSubscriptionEqual compares two subscriptions for equality.
func AssertWithinDuration ¶
AssertWithinDuration asserts that a time is within a duration of now.
func RunMigrations ¶
RunMigrations executes SQL migration files.
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 ¶
TestCache provides cache helpers for testing.
func SetupTestCache ¶
SetupTestCache creates a new test Redis cache.
type TestDB ¶
TestDB provides database helpers for testing.
func SetupTestDB ¶
SetupTestDB creates a new test database with migrations applied.
func (*TestDB) ClearTables ¶
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.