aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/api/handler_test.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-03-20 21:30:22 +0900
committernsfisis <nsfisis@gmail.com>2026-03-20 21:30:22 +0900
commitfc191e09c8b1acd8cfefc43a6e678a6d38e4ce12 (patch)
tree933f5d8ac7e87fa6c2b7ca0fe1f2028cf47b2954 /backend/api/handler_test.go
parentcd7a1532535cd5fa314ec4f0c9b51c571f38ec12 (diff)
downloadphperkaigi-2026-albatross-fc191e09c8b1acd8cfefc43a6e678a6d38e4ce12.tar.gz
phperkaigi-2026-albatross-fc191e09c8b1acd8cfefc43a6e678a6d38e4ce12.tar.zst
phperkaigi-2026-albatross-fc191e09c8b1acd8cfefc43a6e678a6d38e4ce12.zip
fix(game): allow participants to view watch states after game finishes
Previously GetWatchLatestStates returned ErrForbidden for participants regardless of game state. Now checks whether the game has finished and permits access once complete. Also fixes config test env var cleanup. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'backend/api/handler_test.go')
-rw-r--r--backend/api/handler_test.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/backend/api/handler_test.go b/backend/api/handler_test.go
index 2dcde29..41c3403 100644
--- a/backend/api/handler_test.go
+++ b/backend/api/handler_test.go
@@ -672,7 +672,15 @@ func TestGetGameWatchRanking_EmptyRanking(t *testing.T) {
}
func TestGetGameWatchLatestStates_Empty(t *testing.T) {
- h := newTestHandler(&mockQuerier{})
+ h := newTestHandler(&mockQuerier{
+ getGameByIDFunc: func(_ context.Context, _ int32) (db.GetGameByIDRow, error) {
+ return db.GetGameByIDRow{
+ GameID: 1,
+ DurationSeconds: 300,
+ StartedAt: pgtype.Timestamp{Time: time.Now().Add(-10 * time.Minute), Valid: true},
+ }, nil
+ },
+ })
user := &db.User{UserID: 1}
resp, err := h.GetGameWatchLatestStates(context.Background(), GetGameWatchLatestStatesRequestObject{GameID: 1}, user)
if err != nil {