38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package growthreport
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestRequestHashIsStableAndScopeSensitive(t *testing.T) {
|
|
t.Parallel()
|
|
a := RequestHash(7, "T-1", false)
|
|
if a != RequestHash(7, "T-1", false) {
|
|
t.Fatal("RequestHash() is not stable")
|
|
}
|
|
if a == RequestHash(7, "T-2", false) || a == RequestHash(7, "T-1", true) {
|
|
t.Fatal("RequestHash() ignored request scope")
|
|
}
|
|
}
|
|
|
|
func TestNextTehranRefreshUsesCalendarBoundary(t *testing.T) {
|
|
t.Parallel()
|
|
now := time.Date(2026, 8, 21, 20, 0, 0, 0, time.UTC)
|
|
next := NextTehranRefresh(now)
|
|
location, _ := time.LoadLocation("Asia/Tehran")
|
|
local := next.In(location)
|
|
if local.Hour() != 0 || local.Minute() != 0 || !next.After(now) {
|
|
t.Fatalf("NextTehranRefresh() = %s", next)
|
|
}
|
|
}
|
|
|
|
func TestEstimatedTokenReservationCoversTwoTurnsAndGrowsWithEvidence(t *testing.T) {
|
|
t.Parallel()
|
|
small := EstimatedTokenReservation([]byte("{}"))
|
|
large := EstimatedTokenReservation(make([]byte, 1000))
|
|
if small < 3200 || large <= small || large != 5200 {
|
|
t.Fatalf("reservations small=%d large=%d", small, large)
|
|
}
|
|
}
|