40 lines
695 B
Go
40 lines
695 B
Go
package testutils
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func SetupTestDatabase() {
|
|
slog.Info("SetupTestDatabase")
|
|
}
|
|
|
|
func PatchDatabase() {
|
|
slog.Info("PatchDatabase")
|
|
}
|
|
|
|
func TearDownTestDatabase() {
|
|
slog.Info("TearDownTestDatabase")
|
|
}
|
|
|
|
func UnpatchDatabase() {
|
|
slog.Info("UnpatchDatabase")
|
|
}
|
|
|
|
func InitializeTestSuite(m *testing.M) {
|
|
slog.Info("InitializeTestSuite")
|
|
// Initialize the test database
|
|
SetupTestDatabase()
|
|
// Patch the global database.DB to use the TestDB
|
|
PatchDatabase()
|
|
// Run all tests
|
|
code := m.Run()
|
|
// Teardown the database connection
|
|
TearDownTestDatabase()
|
|
// Unpatch the database
|
|
UnpatchDatabase()
|
|
// Exit with the test run status code
|
|
os.Exit(code)
|
|
}
|