fix(multiplayer): finalize empty ranked seasons

This commit is contained in:
Josh Creek
2026-09-01 21:30:23 +01:00
parent 836cedec3c
commit 96f311c129
4 changed files with 39 additions and 0 deletions
+20
View File
@@ -1255,6 +1255,26 @@ func TestPostgreSQLRankedSeasonRolloverIsExactlyOnce(t *testing.T) {
}
}
func TestPostgreSQLEmptyRankedSeasonIsMarkedRolledOver(t *testing.T) {
db := openIntegrationPostgres(t)
applyIntegrationMigrations(t, db)
now := time.Now().UTC().Truncate(time.Microsecond)
ctx := context.Background()
if _, err := db.ExecContext(ctx, `INSERT INTO seasons (season_id, playlist, starts_at, ends_at) VALUES ('empty-season', 'ranked', $1, $2)`, now.Add(-12*7*24*time.Hour), now); err != nil {
t.Fatal(err)
}
if count, err := RolloverDueSeasons(ctx, db, now, 100); err != nil || count != 0 {
t.Fatalf("empty-season maintenance count=%d err=%v", count, err)
}
var rolledAt sql.NullTime
if err := db.QueryRowContext(ctx, `SELECT rolled_over_at FROM seasons WHERE season_id = 'empty-season'`).Scan(&rolledAt); err != nil {
t.Fatal(err)
}
if !rolledAt.Valid {
t.Fatal("empty ranked season was not marked rolled over")
}
}
func TestPostgreSQLMigrationsAreForwardExecutable(t *testing.T) {
db := openIntegrationPostgres(t)
applyIntegrationMigrations(t, db)