WiiCITMS/test/helpers_test.go
2025-11-07 14:14:34 +08:00

24 lines
590 B
Go

package test
import (
"os"
"testing"
"WiiGoLibrary/framework/hub/v1/dblib"
"WiiGoLibrary/framework/hub/v1/server"
)
// TestMain sets up the application hub with DB before running tests.
// It relies on the same configuration mechanism as main.go.
func TestMain(m *testing.M) {
// Initialize hub with DB and automigrate enabled, similar to main.go
_, err := server.New(server.Config{}, server.WithDB(&dblib.DBLibConfig{AutoMigrate: true}))
if err != nil {
// If hub initialization fails, exit with non-zero to surface the issue
os.Exit(1)
}
code := m.Run()
os.Exit(code)
}