test

package
v0.0.0-...-430e8a6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTime

func FormatTime(t time.Time) string

FormatTime formats a time per the presentation output

func InjectClaims

func InjectClaims(claims MockClaims, next http.Handler) http.Handler

InjectClaims injects claims into the current request

func SetStaticClock

func SetStaticClock(now time.Time) (nowStr string, reset func())

SetStaticClock sets the clock to a static time for testing

func Strp

func Strp(str string) *string

Strp returns a pointer to the passed-in string

Types

type AuthMock

type AuthMock struct {
	auth.Auth
}

AuthMock contains dependencies for the AuthMock handler

func NewAuthMock

func NewAuthMock(l auth.Logger) *AuthMock

NewAuthMock returns a mock AuthMock struct

func (*AuthMock) Authenticate

func (a *AuthMock) Authenticate(next http.Handler) http.Handler

Authenticate authenticates a request and calls the next handler

type MockAPI

type MockAPI struct {
	API          http.Handler
	UserRepo     usecase.UserRepo
	TaskRepo     usecase.TaskRepo
	ScheduleRepo usecase.ScheduleRepo
}

MockAPI contain the API mock and repos used during setup

func (*MockAPI) NewUserWithPerm

func (m *MockAPI) NewUserWithPerm(displayname string, provider string, externalID string, perm auth.Permission) (*user.User, http.Handler)

NewUserWithPerm creates and adds a new user and injects a mock permission claim for them in the returned http.Handler

func (*MockAPI) NewUserWithPerms

func (m *MockAPI) NewUserWithPerms(displayname string, provider string, externalID string, perms []auth.Permission) (*user.User, http.Handler)

NewUserWithPerms creates and adds a new user and injects mock permission claims for them in the returned http.Handler

type MockClaims

type MockClaims struct {
	Issuer      string
	Subject     string
	Permissions []auth.Permission
}

MockClaims contains static claims to inject in request

type Tester

type Tester interface {
	NewAPI() MockAPI
	Close() error
}

Tester describes an API struct used to create new test API instances

func NewPostgresTester

func NewPostgresTester() Tester

NewPostgresTester returns a tester struct for creating APIs with a Postgres DB

func NewTransientTester

func NewTransientTester() Tester

NewTransientTester returns a tester struct for creating APIs with a transient in-memory DB

Jump to

Keyboard shortcuts

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