Add CreateTestDatabase function for parallel isolated test databases per package. - Add CreateTestDatabase() for isolated test DBs (parallel-safe) - Move all TestMain functions to per-package testmain_test.go files - Remove old TestMain from handlers_test.go, jwt_test.go, main_test.go - Add JWT init guard in main.go to skip when -test.* flags detected - Update testdb.go with admin DSN and proper cleanup - Rename test database to crussell_test_db for consistency - Replace testdb.NewPool + testdb.Migrate pattern with CreateTestDatabase Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
23 lines
370 B
Go
23 lines
370 B
Go
//go:build test
|
|
// +build test
|
|
|
|
package today
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"crussell/db"
|
|
"crussell/testutils/jwt"
|
|
"crussell/testutils/testdb"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
pool := testdb.CreateTestDatabase("crussell_test_handlers_today")
|
|
db.DB = pool
|
|
jwt.Init()
|
|
code := m.Run()
|
|
testdb.DestroyTestDatabase(pool, "crussell_test_handlers_today")
|
|
os.Exit(code)
|
|
}
|