From 535f0dd95f2ea8c8545834822416c8db3c45397c Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 12 Nov 2026 00:09:34 +0800 Subject: [PATCH] gateway tests: reservations crossing a window skip total, which has no boundary (#6165) ab5824aee added "total" to access.Periods. TestKeyLimitReservationsStayInTheirWindow loops over every period and moves the clock past the window's end, but a total window runs from Since (or the epoch) for 100 years, so a reservation made before the "boundary" is still in the same window after it, and the test went red on total/tokens and total/cost. ab5824aee's run record covers internal/access, budget, cli and provider, not internal/gateway. The total window's own reservations are held by internal/budget's total_test.go. Run (mote): the old file is red on total/tokens and total/cost, the fixed file passes -run TestKeyLimit, and the whole ./internal/gateway package is ok (1001s, -tags nogui -count=1 -timeout 45m). gofmt clean. --- internal/gateway/key_limit_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/gateway/key_limit_test.go b/internal/gateway/key_limit_test.go index 20801597e..e81b9213b 100644 --- a/internal/gateway/key_limit_test.go +++ b/internal/gateway/key_limit_test.go @@ -252,6 +252,9 @@ func TestKeyLimitWindowResets(t *testing.T) { // reservation. A late check or release of it cannot spend the new window. func TestKeyLimitReservationsStayInTheirWindow(t *testing.T) { for _, period := range access.Periods { + if period == "total" { + continue // one window that never ends: no boundary to cross (internal/budget's total_test.go holds it) + } for _, cap := range []struct { name string tokens int64