Documentation ¶
Index ¶
- Constants
- type Dumper
- type Loader
- type WPgxTestSuite
- func (suite *WPgxTestSuite) DumpState(filename string, dumper Dumper)
- func (suite *WPgxTestSuite) GetRawPool() *pgxpool.Pool
- func (suite *WPgxTestSuite) Golden(dbName string, dumper Dumper)
- func (suite *WPgxTestSuite) LoadState(filename string, loader Loader)
- func (suite *WPgxTestSuite) SetupTest()
- func (suite *WPgxTestSuite) TearDownTest()
Constants ¶
const (
TestDataDirPath = "testdata"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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/sample1.golden.json".
func (*WPgxTestSuite) GetRawPool ¶ added in v0.1.1
func (suite *WPgxTestSuite) GetRawPool() *pgxpool.Pool
returns a raw *pgx.Pool
func (*WPgxTestSuite) Golden ¶ added in v0.1.1
func (suite *WPgxTestSuite) Golden(dbName 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()