Documentation
¶
Overview ¶
Package sqlxtest runs a store's test suite against every SQL dialect.
Before the sqlx adapter existed, each store was written twice and only the SQLite half was tested: 18 of 22 PostgreSQL store implementations had no test that touched a database. A single implementation behind sqlx.DB means one suite can cover both backends, so store tests should call Run rather than opening a *sql.DB directly.
SQLite always runs, in memory. PostgreSQL runs only when GOMODEL_TEST_POSTGRES_URL is set; otherwise that subtest skips. A set but unreachable URL fails the test rather than skipping, so CI cannot stay green while the server it started is not the one being tested. The variable is deliberately not POSTGRES_URL — pointing a suite that creates and drops schemas at a configured application database should take a separate, explicit opt-in.
Index ¶
Constants ¶
const PostgresURLEnv = "GOMODEL_TEST_POSTGRES_URL"
PostgresURLEnv names the environment variable holding the test PostgreSQL connection string.
Variables ¶
This section is empty.
Functions ¶
func NewPostgresPool ¶
NewPostgresPool returns a connection pool scoped to a throwaway schema, or nil after skipping when no test server is configured.
Run is the right entry point for a store written against sqlx.DB. This is for the few tests that also need the raw pool — a store that has not moved onto sqlx yet takes *pgxpool.Pool directly, and a test spanning both wants them pointed at one schema.
Types ¶
This section is empty.