Fix: unittests

This commit is contained in:
Grail Finder
2025-07-02 19:00:39 +03:00
parent a438d5b665
commit 130ed3763b
15 changed files with 227 additions and 245 deletions

View File

@ -46,11 +46,11 @@ func HandleCreateRoom(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
if err := repo.PlayerSetRoomID(fi.State.Username, room.ID); err != nil {
if err := repo.PlayerSetRoomID(r.Context(), fi.State.Username, room.ID); err != nil {
abortWithError(w, err.Error())
return
}
// if err := saveFullInfo(fi); err != nil {
// if err := saveFullInfo(r.Context(), fi); err != nil {
// msg := "failed to set current room to session"
// log.Error(msg, "error", err)
// abortWithError(w, msg)
@ -131,7 +131,7 @@ func HandleEndTurn(w http.ResponseWriter, r *http.Request) {
fi.Room.ChangeTurn()
fi.Room.MimeDone = false
StopTurnTimer(fi.Room.ID)
if err := saveFullInfo(fi); err != nil {
if err := saveFullInfo(r.Context(), fi); err != nil {
abortWithError(w, err.Error())
return
}
@ -174,7 +174,7 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) {
Action: models.ActionTypeGameStarted,
}
fi.Room.ActionHistory = append(fi.Room.ActionHistory, action)
if err := saveFullInfo(fi); err != nil {
if err := saveFullInfo(r.Context(), fi); err != nil {
abortWithError(w, err.Error())
return
}
@ -226,7 +226,7 @@ func HandleJoinRoom(w http.ResponseWriter, r *http.Request) {
fi.State.RoomID = room.ID
fi.Room = room
fi.List = nil
if err := saveFullInfo(fi); err != nil {
if err := saveFullInfo(r.Context(), fi); err != nil {
abortWithError(w, err.Error())
return
}
@ -297,7 +297,7 @@ func HandleGiveClue(w http.ResponseWriter, r *http.Request) {
log.Debug("given clue", "clue", clue, "limit", fi.Room.ThisTurnLimit)
notify(models.NotifyBacklogPrefix+fi.Room.ID, clue+num)
notifyBotIfNeeded(fi.Room)
if err := saveFullInfo(fi); err != nil {
if err := saveFullInfo(r.Context(), fi); err != nil {
abortWithError(w, err.Error())
return
}