Documentation
¶
Overview ¶
Package pgtest starts a real PostgreSQL with a schema.sql applied, for testing the database side of an application (views, functions, triggers, constraints) from Go the same way the checker's oracle does. Nothing persists: the server lives in a temporary directory and dies with Close.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadSchema ¶
ReadSchema reads a schema.sql file, or a directory of *.sql files applied in name order, the same way the checker does, for passing to Start.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a running PostgreSQL with the schema applied.
func Start ¶
Start launches PostgreSQL (embedded binary, downloaded on first use) and applies schemaSQL.
func (*DB) ConnString ¶
ConnString connects other clients (a pgxpool.Pool, psql) to the same server.
func (*DB) Verify ¶
Verify checks that the analyzer agrees with this PostgreSQL about each statement: every expansion of the template (each combination of its branches) is prepared by PG, and PG's parameter types, result column names and types, or its rejection, are compared with what the checker concluded. A disagreement means the checker's verdict on that statement cannot be trusted; the error lists each one with the SQL and both descriptions. Put it in a test next to Start so the application carries the evidence that its static checks hold for the PostgreSQL it runs on.