- Add TestMain to all 10 test packages (schema DROP+CREATE runs once per package) - Convert per-test setupTestDB to resetTestData (TRUNCATE only, ~60% faster) - Add 3 missing tables to TruncateTables (booking_edit_requests, exceptional_group_applications, business_settings) - Remove dead truncateDiscountTables helper - Consolidate discount_test.go into package bookings (was external test package) - Update testutils.SetupTestDB to truncate-only - Fix unused imports across user, bookings, and handlers packages - Verify: 286 passing, 2 skipped, 0 failures with -count=2 (no state leakage)
26 lines
355 B
Go
26 lines
355 B
Go
//go:build test
|
|
// +build test
|
|
|
|
package bookings
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"crussell/db"
|
|
"crussell/testutils/testdb"
|
|
"crussell/testutils/jwt"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
pool, err := testdb.NewPool("")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
testdb.Migrate(&testing.T{}, pool)
|
|
db.DB = pool
|
|
jwt.Init()
|
|
code := m.Run()
|
|
pool.Close()
|
|
os.Exit(code)
|
|
} |