Documentation
¶
Index ¶
- func CloseConnection()
- func ConnectAndMigrateDB(packageName string)
- func ConnectToTestDB(dbSchema string)
- func CreateFixtures(schema string)
- func CreateTestDB()
- func DoneWithFixtures(schema string)
- func DropSchema(dbSchema string)
- func MigrateSchema()
- func SwitchSchema(schema string)
- func UpdateTablesSequences()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseConnection ¶
func CloseConnection()
CloseConnection closes the connection to the database. Useful to avoid the "max connections reached" error due to the many database tests we have.
func ConnectAndMigrateDB ¶
func ConnectAndMigrateDB(packageName string)
func ConnectToTestDB ¶
func ConnectToTestDB(dbSchema string)
ConnectToTestDB connects to the test database, populates the "dao.DB" member, and runs a schema migration.
func CreateFixtures ¶
func CreateFixtures(schema string)
CreateFixtures creates a new schema, migrates the schema and adds the required fixtures for the tests.
func CreateTestDB ¶
func CreateTestDB()
CreateTestDB creates a test database. The function terminates the program with a code 0 if the creating is successful.
func DoneWithFixtures ¶
func DoneWithFixtures(schema string)
DoneWithFixtures drops the schema and returns the "DB" object back to the "public" schema, in case any other tests need the database in the previous schema.
func SwitchSchema ¶
func SwitchSchema(schema string)
SwitchSchema switches the schema to the specified one, migrates the schema and creates the fixtures for it.
func UpdateTablesSequences ¶
func UpdateTablesSequences()
UpdateTablesSequences loops over all the tables from the database to update the tables' sequences to the latest id. When inserting data with an ID, for example `INSERT INTO mytable(id, desc) VALUES (1, "My description")`, the sequence doesn't get updated because an explicit ID was given. Therefore, if in the subsequent calls the ID is omitted, this could lead to "unique constraint violation" errors because of a duplicate id.
Types ¶
This section is empty.