tests

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Unlicense Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Success = "\u2713"
	Failed  = "\u2717"
)

Success and failure markers.

Variables

This section is empty.

Functions

func Context

func Context() context.Context

Context returns an app level context for testing.

func IntPointer

func IntPointer(i int) *int

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

func NewUnit(t *testing.T) (*pgxpool.Pool, func())

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 is 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

func StringPointer(s string) *string

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.

func TimePointer

func TimePointer(t time.Time) *time.Time

TimePointer is a helper to get a *time from a time.

Types

type Container added in v0.1.3

type Container struct {
	// contains filtered or unexported fields
}

func NewContainer added in v0.1.3

func NewContainer(pool, repository, tag string, cmd, env []string) (*Container, error)

type ContainerSpec added in v0.1.3

type ContainerSpec struct {
	Repository string
	Tag        string
	Port       string
	Args       []string
	Cmd        []string
}

ContainerSpec provides configuration for a docker container to run.

func NewPostgresDBSpec added in v0.1.3

func NewPostgresDBSpec() ContainerSpec

func NewRoachDBSpec added in v0.1.3

func NewRoachDBSpec() ContainerSpec

type Test

type Test struct {
	DB  *pgxpool.Pool
	Log *log.Logger
	// contains filtered or unexported fields
}

Test owns state for running and shutting down tests.

func NewIntegration

func NewIntegration(t *testing.T) *Test

NewIntegration creates a database, seeds it, constructs an authenticator.

func (*Test) Teardown

func (test *Test) Teardown()

Teardown releases any resources used for the test.

Jump to

Keyboard shortcuts

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