From 6cc78e8aade1c99fd7a7d2d199a55ce0fa8e5685 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 6 Nov 2026 18:39:27 +0800 Subject: [PATCH] provider: the keep-alive tests' Claude week resets days from now, not on Nov 6 (#5481) TestRenewLoginsKeepsClaudeReading was red on every run since 07:00 UTC 11-06. Its /usage fixture says "resets Nov 6 at 11am (Asia/Dubai)", which is 07:00 UTC 11-06, and the keep-alive reads it at the real time. Once that hour went by the week counted as reset, so the reading had Used 0 where the test wants 37. The issue was filed at 07:15 UTC. resetsAhead writes the reset three days past now, for this test and for TestRenewLoginsKeepsSavedClaudeSignedIn, which had the same fixed date and didn't yet check Used. TestClaudeUsageWeeklyOnly holds its own clock and keeps the reporter's text. Run on mote: without the fix, -run TestRenewLoginsKeepsClaudeReading -count=5 is red 5 of 5 now. With it, -run 'TestRenewLogins| TestClaudeUsageWeeklyOnly' -count=3 is green under TZ=UTC, Pacific/Kiritimati and America/Los_Angeles. internal/provider whole: ok at c6b7bbedf (598s), beside the image commit before this one. Both commits, rebased on 9a0aab32c (6 commits, none in these files), then on 8f69ca29c (browser only; go vet ./... and go build ok there): gateway, imagemcp and provider vet on darwin, linux nogui and windows ok, go build ok; the gateway image, draw, Codex, Copilot and MCP tests, internal/imagemcp and the provider keep-alive and Claude usage tests ok. --- internal/provider/keepalive_claude_test.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/internal/provider/keepalive_claude_test.go b/internal/provider/keepalive_claude_test.go index 21ff4f422..82c55cf73 100644 --- a/internal/provider/keepalive_claude_test.go +++ b/internal/provider/keepalive_claude_test.go @@ -22,7 +22,7 @@ func TestRenewLoginsKeepsSavedClaudeSignedIn(t *testing.T) { claudeThree(t) // team@ and max@ saved, Claude Code on pro@ keepAliveClean(t) var text atomic.Value - text.Store("Current week (all models): 1% used · resets Nov 6 at 11am (Asia/Dubai)") + text.Store(resetsAhead("Current week (all models): 1% used · resets Nov 6 at 11am (Asia/Dubai)")) fakeClaudeUsage(t, &text, nil) var mu sync.Mutex var dirs []string @@ -151,6 +151,17 @@ func TestRenewLoginsKeepsSavedClaudeSignedIn(t *testing.T) { } } +// resetsAhead moves a /usage text's "resets Nov 6 at 11am" three days past +// now: these tests read at the real time, and once that hour went by the +// week read as reset, Used 0 (#5481). +func resetsAhead(text string) string { + dubai, err := time.LoadLocation("Asia/Dubai") + if err != nil { + panic(err) + } + return strings.ReplaceAll(text, "Nov 6 at 11am", time.Now().In(dubai).AddDate(0, 0, 3).Format("Jan 2 at 3pm")) +} + // keepAliveClean has the test start, and leave, with no renewal on record // as failed (renewWaiting) and no reading kept from another test. func keepAliveClean(t *testing.T) { @@ -180,12 +191,12 @@ func TestRenewLoginsKeepsClaudeReading(t *testing.T) { claudeThree(t) keepAliveClean(t) var text atomic.Value - text.Store(claudeWeeklyOnly) + text.Store(resetsAhead(claudeWeeklyOnly)) fakeClaudeUsage(t, &text, nil) runs := atomic.Int32{} UsageClaudeVia(func(_ context.Context, dir string) (string, error) { runs.Add(1) - return strings.Replace(claudeWeeklyOnly, "(all models): 1%", "(all models): 37%", 1), nil + return strings.Replace(resetsAhead(claudeWeeklyOnly), "(all models): 1%", "(all models): 37%", 1), nil }) max := "max@x.com" var l Login