mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-21 23:22:34 +01:00
refactor(channelserver): extract FestaRepository and TowerRepository
Move all direct DB calls from handlers_festa.go (23 calls across 8 tables) and handlers_tower.go (16 calls across 4 tables) into dedicated repository structs following the established pattern. FestaRepository (14 methods): lifecycle cleanup, event management, team souls, trial stats/rankings, user state, voting, registration, soul submission, prize claiming/enumeration. TowerRepository (12 methods): personal tower data (skills, progress, gems), guild tenrouirai progress/scores/page advancement, tower RP. Also fix pre-existing nil pointer panics in integration tests by adding SetTestDB helper that initializes both the DB connection and all repositories, and wire the done channel in createTestServerWithDB to prevent Shutdown panics.
This commit is contained in:
@@ -329,3 +329,16 @@ func CreateTestGuild(t *testing.T, db *sqlx.DB, leaderCharID uint32, name string
|
||||
|
||||
return guildID
|
||||
}
|
||||
|
||||
// SetTestDB assigns a database to a Server and initializes all repositories.
|
||||
// Use this in integration tests instead of setting s.server.db directly.
|
||||
func SetTestDB(s *Server, db *sqlx.DB) {
|
||||
s.db = db
|
||||
s.charRepo = NewCharacterRepository(db)
|
||||
s.guildRepo = NewGuildRepository(db)
|
||||
s.userRepo = NewUserRepository(db)
|
||||
s.gachaRepo = NewGachaRepository(db)
|
||||
s.houseRepo = NewHouseRepository(db)
|
||||
s.festaRepo = NewFestaRepository(db)
|
||||
s.towerRepo = NewTowerRepository(db)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user