testutil

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DBInsertTimeTolerance = 100 * time.Millisecond

Variables

View Source
var ErrTestFailure = errors.New("test failure")
View Source
var Migrations embed.FS
View Source
var MigrationsDir = "migrations"

Functions

This section is empty.

Types

type TestSuite

type TestSuite struct {
	suite.Suite

	TestCtx context.Context //nolint:containedctx

	DB *sql.DB
	SB squirrel.StatementBuilderType
	// contains filtered or unexported fields
}

TestSuite is a test suite that provides a Postgres instance and a DB connection. Make sure to call SetupDB() in your suite setup, and CloseDB() in your suite teardown.

func (*TestSuite) Address

func (s *TestSuite) Address() string

Address returns the address of the Postgres instance.

func (*TestSuite) ApproxEqualTime

func (s *TestSuite) ApproxEqualTime(t1 time.Time, t2 time.Time)

ApproxEqualTime asserts that the two given times are within the database insert time tolerance.

func (*TestSuite) CloseDB

func (s *TestSuite) CloseDB()

CloseDB closes the DB connection and terminates the Postgres instance.

func (*TestSuite) SetupDB

func (s *TestSuite) SetupDB(migrations embed.FS, migrationsDir string)

SetupDB creates a new Postgres instance and a DB connection.

func (*TestSuite) TruncateTables

func (s *TestSuite) TruncateTables(tables ...string)

TruncateTables truncates the given tables.

Jump to

Keyboard shortcuts

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