Documentation
¶
Overview ¶
Package pgtest gives a test its own Postgres schema.
The index is the one part of this repository that cannot be tested without a database. Rather than mock it — a mocked index would agree with whatever the code did and prove nothing about idempotency, which is the whole contract — the tests that need Postgres skip when none is configured. A contributor without one still runs everything else, and `just check` stays hermetic.
Index ¶
Constants ¶
const ( Writer = "audit_writer" Observe = "audit_observe" Purge = "audit_purge" )
The roles of the parts, as a deployment's migration job names them.
const Reader = "audit_reader"
Reader is the role a reading service connects as.
It exists because row-level security does not apply to the role that owns the tables, and the tests all connect as that role. A policy exercised only by its owner is a policy nobody has read: it passes whatever it says. So a test about isolation has to come in as somebody else, and this is the somebody.
const URLEnv = "AUDIT_POSTGRES_URL"
URLEnv names the database the Postgres tests run against.
Variables ¶
This section is empty.
Functions ¶
func AsReader ¶
AsReader returns a pool on the same schema connected as a role that row-level security applies to, with select granted and nothing else.
It is deliberately not given insert: a reader that could write the trail it reads is not a reader, and the grant is the place that has to say so.
Types ¶
This section is empty.