mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-16 09:22:21 +00:00
feat: add ranked season window policy
This commit is contained in:
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user