feat: Complete DI cleanup - migrate test helpers to Database struct
- Update internal/db/test_helpers.go to use Database struct instead of globals - Update internal/server/test_helpers.go to use TestDatabase.Pool - Add TODO comment to old Dbpool/Ctx globals in dbHelper.go - Remove db.Testf() usage from production code (kept for deprecated /dbtest endpoint) Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -51,19 +51,16 @@ func StartTestServer(t *testing.T) *echo.Echo {
|
||||
// Initialize database for tests
|
||||
db.TestSetupDB(t)
|
||||
|
||||
// Initialize backend with the global Dbpool
|
||||
// Initialize backend with test database pool
|
||||
// This ensures BackendRepo() and BackendCtx() are available
|
||||
if db.Dbpool != nil {
|
||||
backend.InitBackend(db.Dbpool)
|
||||
if db.TestDatabase != nil && db.TestDatabase.Pool != nil {
|
||||
backend.InitBackend(db.TestDatabase.Pool)
|
||||
}
|
||||
|
||||
// Create a Server instance and get its routes
|
||||
s := &Server{
|
||||
db: &db.Database{
|
||||
Pool: db.Dbpool,
|
||||
Ctx: db.Ctx,
|
||||
},
|
||||
tokenHandler: NewTokenHandler(db.Dbpool),
|
||||
db: db.TestDatabase,
|
||||
tokenHandler: NewTokenHandler(db.TestDatabase.Pool),
|
||||
}
|
||||
handler := s.RegisterRoutes()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user