You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
993 B
Go
37 lines
993 B
Go
package model
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestApplyBuffQuotaRollover_RefillsWhenWindowPassed(t *testing.T) {
|
|
end := time.Date(2026, 3, 1, 12, 0, 0, 0, time.UTC)
|
|
h := &Hero{
|
|
BuffFreeChargesRemaining: 0,
|
|
BuffQuotaPeriodEnd: &end,
|
|
}
|
|
now := end.Add(time.Hour)
|
|
if !h.ApplyBuffQuotaRollover(now) {
|
|
t.Fatal("expected rollover to mutate hero")
|
|
}
|
|
if h.BuffFreeChargesRemaining != FreeBuffActivationsPerPeriod {
|
|
t.Fatalf("charges: want %d, got %d", FreeBuffActivationsPerPeriod, h.BuffFreeChargesRemaining)
|
|
}
|
|
if !h.BuffQuotaPeriodEnd.After(end) {
|
|
t.Fatalf("expected period end to advance, got %v", h.BuffQuotaPeriodEnd)
|
|
}
|
|
}
|
|
|
|
func TestApplyBuffQuotaRollover_NoOpWhenSubscribed(t *testing.T) {
|
|
end := time.Date(2026, 3, 1, 12, 0, 0, 0, time.UTC)
|
|
h := &Hero{
|
|
SubscriptionActive: true,
|
|
BuffFreeChargesRemaining: 0,
|
|
BuffQuotaPeriodEnd: &end,
|
|
}
|
|
if h.ApplyBuffQuotaRollover(end.Add(48 * time.Hour)) {
|
|
t.Fatal("subscription should skip rollover")
|
|
}
|
|
}
|