Use test database for all tests
Related tasks
Context
Tests need to initialize database tables and data in order to work. Cloudsim automatically appends a _test
suffix to the database name when running tests.
Some tests have their own database initialization code and were manually calling ign.NewDatabaseConfigFromEnvVars
and ign.InitDbWithCfg
. These calls do not append the _test
suffix automatically, which made tests operate on the application database directly.
Change
A helper function gorm.GetTestDBFromEnvVars()
is available to get a test database. This function does append the _test
suffix before creating and returning a database connection.
Other information
Using an alternative DB should not be configured in the code, but through an environment variable used when testing instead.
Additional documentation
Edited by Alejo Carballude