testhelpers

package
v0.0.0-...-f1c2737 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanupTestDb

func CleanupTestDb(db *sqlx.DB) error

CleanupTestDb truncates tables that are usually populated with fixtures. The set of tables is hardcoded.

func CountTable

func CountTable(tableName string, db *sqlx.DB) int

CountTable counts all rows in a table. Useful for testing whether a create or delete succeeded.

func DropAllTables

func DropAllTables(db *sqlx.DB) error

DropAllTables enumerates all tables and drops them.

func GetStandardConfig

func GetStandardConfig() config.ServiceConfig

func InitializeDatabase

func InitializeDatabase(db *sqlx.DB, migrationsDir, fixturesDir string) error

InitializeDatabase drops all tables in the provided database, then runs the migrations found in the migrationsDir, then loads the fixtures found in fixturesDir.

func LoadFixtures

func LoadFixtures(db *sqlx.DB, fixturesDirectory string) error

LoadFixtures scans the given directory for .sql files and runs all of them on the given DB handle. They will run in filesystem order, not sorted.

Types

type DatabaseTestingSuite

type DatabaseTestingSuite struct {
	suite.Suite
	Config *config.ServiceConfig
	// contains filtered or unexported fields
}

func (*DatabaseTestingSuite) AfterTest

func (suite *DatabaseTestingSuite) AfterTest(suiteName, testName string)

func (*DatabaseTestingSuite) BeforeTest

func (suite *DatabaseTestingSuite) BeforeTest(suiteName, testName string)

Perform initialization required by each test function

func (*DatabaseTestingSuite) SetupAllSuite

func (suite *DatabaseTestingSuite) SetupAllSuite()

Perform global setup

Jump to

Keyboard shortcuts

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