tester

package
v0.0.0-...-6251ae7 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package tester provides a testing framework for the complete project.

Index

Constants

View Source
const (
	MigrDriverEnvKey  = "MIGRATION_DRIVER"
	DefaultMigrDriver = "pgx"
	DSNEnvKey         = "DB_URL"
	DefaultDSN        = "postgresql://muhlemmer@db:5432/muhlemmer?sslmode=disable"
)

Database configuration

Variables

This section is empty.

Functions

func Run

func Run(timeout time.Duration, run func(r *Resources) int) int

Run resets the database by migrating Down and Up.

The run function is meant to iniate tests and supply them with Resources as required, returning the value from testing.M.Run().

Database configuration is taken from the environment. See package constants for more details.

func RunWithData

func RunWithData(timeout time.Duration, run func(r *Resources) int) int

RunWithData resets the database by migrating Down and Up and generating testdata in all tables. The limits of the generated data can be found in Resources, passed to the run function. The run function is meant to iniate tests and supply them with Resources as required, returning the value from testing.M.Run().

Database configuration is taken from the environment. See package constants for more details.

Types

type Resources

type Resources struct {
	CTX    context.Context
	ErrCTX context.Context

	DSN  string
	Pool *pgxpool.Pool

	RequestBegin     time.Time
	RequestsEnd      time.Time
	DailyTotalsBegin time.Time
	DailyTotalsEnd   time.Time

	MethodIDs []pgtype.Int8
}

Resources caries data for testing.

Jump to

Keyboard shortcuts

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