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.
This commit is contained in:
yetone
2026-11-06 18:48:50 +08:00
parent e0a7664b53
commit 6cc78e8aad
+14 -3
View File
@@ -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