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:
2026-06-01 20:06:47 +02:00
parent 2f407f6eef
commit c60f40d7e3
3 changed files with 28 additions and 14 deletions
+5 -8
View File
@@ -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()