testutil

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package testutil holds small helpers shared by Go tests across packages. It is imported only from *_test.go files, never from production code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FutureRFC3339

func FutureRFC3339(hours int) string

FutureRFC3339 returns an RFC3339 (UTC) timestamp `hours` from now, mirroring the TypeScript aheadByHours (ui/src/app/lib/test-clock.ts). Use it instead of a literal calendar date in a fixture, which goes stale once the wall clock catches up to it. Negative hours give an already-expired timestamp.

A fixture meant to read as "live" (not merely unexpired) needs to clear both modelAccessExpiringWindow (24h) and the AWS SSO refresh skew, or grading logic will call it "expiring" — 24*30 is what this codebase uses for that case.

func PGConn added in v0.8.9

func PGConn(t *testing.T, pool *pgxpool.Pool) *pgx.Conn

PGConn opens a separate session for a test's competing database actor. It must not borrow the production path's pool: that would be a nested acquire by the test itself, obscuring what the pool guard is meant to prove.

func Spellings added in v0.8.6

func Spellings(s string) []string

Spellings is every way stored bytes could spell s that a reader undoes with no key: s itself, its hex in either case, and its base64 in either alphabet, padded or not, at each of the three byte alignments it could start on. The characters the bytes before and after s reach into are cut off, so a match is s's own bytes whatever surrounds them. Use it to assert that something is NOT stored: a test that looks only for s misses s base64-encoded.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL