feat: add ranked season window policy

This commit is contained in:
Josh Creek
2026-08-31 21:08:10 +01:00
parent e13a64756f
commit bc7136b2cb
3 changed files with 39 additions and 2 deletions
+19 -1
View File
@@ -1,6 +1,9 @@
package domain
import "testing"
import (
"testing"
"time"
)
func TestRankedProvisionalBoundaryIsFirstTenGames(t *testing.T) {
for games := 0; games < 10; games++ {
@@ -57,3 +60,18 @@ func TestCasualRatingHasNoSeasonOperation(t *testing.T) {
t.Fatal("casual boundary test fixture unexpectedly provisional")
}
}
func TestRankedSeasonWindowIsExactlyTwelveWeeksAndDueIsIdempotent(t *testing.T) {
start := time.Unix(1000, 0)
season, err := NewRankedSeason("season-1", start)
if err != nil || season.EndsAt.Sub(start) != RankedSeasonLength {
t.Fatalf("season = %+v err=%v", season, err)
}
if SeasonRolloverDue(season, season.EndsAt.Add(-time.Nanosecond)) || !SeasonRolloverDue(season, season.EndsAt) {
t.Fatal("season due boundary is wrong")
}
season.RolledOverAt = season.EndsAt
if SeasonRolloverDue(season, season.EndsAt.Add(time.Hour)) {
t.Fatal("completed season remained due")
}
}