Documentation ¶
Overview ¶
Package tests provides helpers that should only be used in testing.
Index ¶
Constants ¶
const ( AdminID = "5cf37266-3473-4006-984f-9325122678b7" UserID = "45b5fbd3-755f-4379-8f07-a58d4a30fa2f" )
These are the IDs in the seed data for admin@example.com and user@example.com.
Variables ¶
This section is empty.
Functions ¶
func IntPointer ¶
IntPointer is a helper to get a *int from a int. It is in the tests package because we normally don't want to deal with pointers to basic types but it's useful in some tests.
func NewUnit ¶
NewUnit creates a test database inside a Docker container. It creates the required table structure but the database is otherwise empty.
It does not return errors as this intended for testing only. Instead it will call Fatal on the provided testing.T if anything goes wrong.
It returns the database to use as well as a function to call at the end of the test.
func StringPointer ¶
StringPointer is a helper to get a *string from a string. It is in the tests package because we normally don't want to deal with pointers to basic types but it's useful in some tests.
Types ¶
type Test ¶
type Test struct { DB *sqlx.DB Log *log.Logger Authenticator *auth.Authenticator // contains filtered or unexported fields }
Test owns state for running and shutting down tests.