From 5ed369a6c70707543fd5ec9a13c79851fdfc5d6c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 15 Feb 2026 22:13:50 +0900 Subject: refactor(backend): introduce DI interfaces for testability Replace concrete *db.Queries and *pgxpool.Pool dependencies with db.Querier and db.TxManager interfaces across all handlers, game hub, and auth. This enables unit testing with mocks. - Enable sqlc emit_interface to generate Querier interface - Add TxManager abstraction to encapsulate transactions - Convert auth package-level functions to Authenticator struct - Add TaskQueueInterface/TaskWorkerInterface for game.Hub - Add initial unit tests for game logic and API handlers Co-Authored-By: Claude Opus 4.6 --- backend/api/handler_wrapper.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'backend/api/handler_wrapper.go') diff --git a/backend/api/handler_wrapper.go b/backend/api/handler_wrapper.go index 7448d13..28b89e4 100644 --- a/backend/api/handler_wrapper.go +++ b/backend/api/handler_wrapper.go @@ -5,8 +5,6 @@ package api import ( "context" - "github.com/jackc/pgx/v5/pgxpool" - "albatross-2026-backend/config" "albatross-2026-backend/db" ) @@ -17,12 +15,13 @@ type HandlerWrapper struct { impl Handler } -func NewHandler(queries *db.Queries, pool *pgxpool.Pool, hub GameHubInterface, conf *config.Config) *HandlerWrapper { +func NewHandler(queries db.Querier, txm db.TxManager, hub GameHubInterface, auth AuthenticatorInterface, conf *config.Config) *HandlerWrapper { return &HandlerWrapper{ impl: Handler{ q: queries, - pool: pool, + txm: txm, hub: hub, + auth: auth, conf: conf, }, } -- cgit v1.3.1