tests

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

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

Success and failure markers.

Variables

View Source
var (
	// IDs from the seed data for admin@example.com and user@example.com.
	AdminID = "5cf37266-3473-4006-984f-9325122678b7"
	UserID  = "45b5fbd3-755f-4379-8f07-a58d4a30fa2f"
)

Configuration for running tests.

Functions

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, ctr ContainerSpec) (*log.Logger, *database.DB, func())

NewUnit creates a test database inside a Docker container. It creates the required table structure but the database is otherwise empty. 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.

Types

type Container

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

func NewContainer

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

func (*Container) TailLogs

func (c *Container) TailLogs(ctx context.Context, w io.Writer, follow bool) error

type ContainerSpec

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.3.4

func NewPostgresDBSpec() ContainerSpec

func NewRoachDBSpec added in v0.3.4

func NewRoachDBSpec() ContainerSpec

type Test

type Test struct {
	Auth     *auth.Auth
	DB       *database.DB
	KID      string
	Log      *log.Logger
	Teardown func()
	TraceID  string
	// contains filtered or unexported fields
}

Test owns state for running and shutting down tests.

func NewIntegration

func NewIntegration(t *testing.T, ctr ContainerSpec) *Test

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

func (*Test) Token

func (test *Test) Token(email, pass string) string

Token generates an authenticated token for a user.

Jump to

Keyboard shortcuts

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