Documentation
¶
Overview ¶
Package testutils provides testing utilities including database containers and test helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTestDataFilePath ¶
GetTestDataFilePath returns the absolute path to a test data file It looks for a "testdata" directory relative to the calling test file
func SetupTestEnv ¶
SetupTestEnv loads environment variables from .env.test file in priority order godotenv.Load() does NOT overwrite existing environment variables, so CI/CD variables (e.g., GitHub Secrets) take precedence automatically
Priority order: 1. Environment variables (CI/CD secrets) - never overwritten 2. .env.test - for test-specific variables
func SetupTestEnvWithRequiredVarsOrSkipTest ¶
SetupTestEnvWithRequiredVarsOrSkipTest loads environment variables and verifies required ones are set Skips the test if any required variable is missing
func SetupTestManager ¶
func SetupTestManager(t testing.TB, opts ...TestManagerOptions) (*database.Manager, func())
SetupTestManager creates a Manager with testcontainer and migrations
Types ¶
type PostgresContainer ¶
type PostgresContainer struct {
*postgres.PostgresContainer
ConnectionString string
}
PostgresContainer embeds the testcontainers PostgresContainer and adds the ConnectionString field.
func SetupPostGISContainer ¶
func SetupPostGISContainer(ctx context.Context) (*PostgresContainer, error)
SetupPostGISContainer creates a PostGIS container with testcontainers
type TestManagerOptions ¶
type TestManagerOptions struct {
// MigrationsPath path to migration files (default: "/migrations" at project root)
MigrationsPath string
// SkipMigrations disables automatic migrations
SkipMigrations bool
// MigrationsSchema schema for migrations table (default: "public")
MigrationsSchema string
// MigrationsTable table name for migrations (default: "schema_migrations")
MigrationsTable string
}
TestManagerOptions sets behavior of SetupTestManager