Documentation
¶
Overview ¶
Package testutil holds the smallest, most widely used test helper: Must. Everything else (fakes, gin contexts, golden files, a test database) lives in its own subpackage so a test imports only what it needs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Must ¶
Must checks the (value, error) pair a fixture call returns and gives back a function that yields the value, or fails the test the way t.Fatalf would. The pair must be Must's only arguments, because Go spreads a multi-value call into another call only when it is the sole argument, so t comes after:
user := testutil.Must(factory.User(ctx, db))(t)
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package factory builds valid rows for pcom's tables so that tests (and cmd/seed) don't have to know the schema.
|
Package factory builds valid rows for pcom's tables so that tests (and cmd/seed) don't have to know the schema. |
|
Package fakesender is a fake of github.com/can3p/pcom/pkg/repo.MailQueue for unit and package tests: it records every mail instead of delivering it.
|
Package fakesender is a fake of github.com/can3p/pcom/pkg/repo.MailQueue for unit and package tests: it records every mail instead of delivering it. |
|
Package fakestorage is an in-memory implementation of github.com/can3p/pcom/pkg/media/server.MediaStorage, for tests that exercise upload/download code without a real object store.
|
Package fakestorage is an in-memory implementation of github.com/can3p/pcom/pkg/media/server.MediaStorage, for tests that exercise upload/download code without a real object store. |
|
Package ginctx builds a *gin.Context for a handler test, wired up the way cmd/web/main.go wires a real request: a cookie-backed session under the name "sess".
|
Package ginctx builds a *gin.Context for a handler test, wired up the way cmd/web/main.go wires a real request: a cookie-backed session under the name "sess". |
|
Package golden compares test output against a checked-in file, the convention docs/testing.md uses for mail content: run with UPDATE_GOLDEN=1 to write the file, and without it to check the current output still matches.
|
Package golden compares test output against a checked-in file, the convention docs/testing.md uses for mail content: run with UPDATE_GOLDEN=1 to write the file, and without it to check the current output still matches. |
|
Package seed fills a development database with a small, named world that exercises every feature of pcom.
|
Package seed fills a development database with a small, named world that exercises every feature of pcom. |
|
Package testdb gives a test its own empty Postgres database with pcom's migrations applied.
|
Package testdb gives a test its own empty Postgres database with pcom's migrations applied. |
|
Package testlog records what code under test logs, so a test can assert on the entries.
|
Package testlog records what code under test logs, so a test can assert on the entries. |
|
Package tommy runs one tommy container (github.com/can3p/tommy) per test binary: the Mailjet API mail is sent to, and the S3 bucket user media is stored in.
|
Package tommy runs one tommy container (github.com/can3p/tommy) per test binary: the Mailjet API mail is sent to, and the S3 bucket user media is stored in. |
|
Package wiremock runs one WireMock container per test binary.
|
Package wiremock runs one WireMock container per test binary. |
Click to show internal directories.
Click to hide internal directories.