Documentation
¶
Overview ¶
Package test ...
Index ¶
- Variables
- func AssertDeleted(t *testing.T, db *app.DB, table string, id ds.ID)
- func AssertInDB(t *testing.T, db *app.DB, table string, data Data)
- func AssertNotInDB(t *testing.T, db *app.DB, table string, data Data)
- func CheckErr(t *testing.T, err error)
- func Create[T any](t *testing.T, f *factory.Factory, overrideOpt ...T) *T
- func LoadEmailVars(t *testing.T, to string) map[string]any
- type App
- type Data
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoFactoryMethod is returned when no suitable factory method // can be found for the requested type. ErrNoFactoryMethod = errors.New("no factory method found") // ErrAmbiguousFactoryMethod is returned when multiple factory methods // match the requested type and the selection is ambiguous. ErrAmbiguousFactoryMethod = errors.New("ambiguous factory method") )
var NotNull notNull
NotNull is the exported constant marker value to assert that a database column must not be NULL. Use it as a value in a Data map: Data{"column_name": test.NotNull}.
Functions ¶
func AssertDeleted ¶
AssertDeleted asserts that row with "deleted_at" is not null.
func AssertInDB ¶
AssertInDB asserts that at least one row exists in the given table that matches the criteria in 'data'.
func AssertNotInDB ¶
AssertNotInDB asserts that no rows exist in the given table that match the criteria in 'data'.
func CheckErr ¶
CheckErr is a test helper function that fails the test immediately if the provided error is not nil.
func Create ¶
Create invokes the corresponding Create{Model} method on factory.Factory, where Model is inferred from T.
Optional overrideOpt values are forwarded as variadic arguments to the underlying factory method. The test fails immediately on any error.
NOTE: Go does not currently allow methods to declare their own type parameters. When this becomes possible, move this helper onto *factory.Factory and remove the wrapper functions. TODO: a promising "Proposal: Generic Methods for Go" have landed: https://github.com/golang/go/issues/77273
Types ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
random
Package random provides utility functions for generating various types of random data.
|
Package random provides utility functions for generating various types of random data. |
|
Package seed provides helpers for seeding test and development data.
|
Package seed provides helpers for seeding test and development data. |