testsuite

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestDataDirPath = "testdata"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dumper

type Dumper interface {
	Dump() ([]byte, error)
}

type Loader

type Loader interface {
	Load(data []byte) error
}

type WPgxTestSuite added in v0.1.1

type WPgxTestSuite struct {
	suite.Suite
	Testdb string
	Tables []string
	Config *wpgx.Config
	Pool   *wpgx.Pool
}

func NewWPgxTestSuiteFromConfig added in v0.1.1

func NewWPgxTestSuiteFromConfig(config *wpgx.Config, db string, tables []string) *WPgxTestSuite

NewWPgxTestSuiteFromConfig connect to PostgreSQL Server according to @p config, @p db is the name of test db and tables are table creation SQL statements. DB will be created, so does tables, on SetupTest. If you pass different @p db for suites in different packages, you can test them in parallel.

func NewWPgxTestSuiteFromEnv added in v0.1.1

func NewWPgxTestSuiteFromEnv(db string, tables []string) *WPgxTestSuite

NewWPgxTestSuiteFromEnv @p db is the name of test db and tables are table creation SQL statements. DB will be created, so does tables, on SetupTest. If you pass different @p db for suites in different packages, you can test them in parallel.

func (*WPgxTestSuite) DumpState added in v0.1.1

func (suite *WPgxTestSuite) DumpState(filename string, dumper Dumper)

Dumpstate dump state to the file. For example DumpState(ctx, "sample1.golden.json") will dump (insert) bytes from dumper.dump() to "testdata/${suitename}/${filename}".

func (*WPgxTestSuite) GetPool added in v0.1.2

func (suite *WPgxTestSuite) GetPool() *wpgx.Pool

GetPool returns the *wpgx.Pool.

func (*WPgxTestSuite) GetRawPool added in v0.1.1

func (suite *WPgxTestSuite) GetRawPool() *pgxpool.Pool

GetRawPool returns a raw *pgx.Pool.

func (*WPgxTestSuite) Golden added in v0.1.1

func (suite *WPgxTestSuite) Golden(tableName string, dumper Dumper)

func (*WPgxTestSuite) LoadState added in v0.1.1

func (suite *WPgxTestSuite) LoadState(filename string, loader Loader)

LoadState load state from the file to DB. For example LoadState(ctx, "sample1.input.json") will load (insert) from "testdata/sample1.input.json" to table

func (*WPgxTestSuite) SetupTest added in v0.1.1

func (suite *WPgxTestSuite) SetupTest()

setup the database to a clean state: tables have been created according to the schema, empty.

func (*WPgxTestSuite) TearDownTest added in v0.1.1

func (suite *WPgxTestSuite) TearDownTest()

Jump to

Keyboard shortcuts

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