Commit Graph
4 Commits
Author SHA1 Message Date
yetone 49caff3caf provider tests: a no-wait return is asserted by holding the slow thing, not a wall-clock bound (#1617)
The siblings of #1586 that 7b151cf54 left alone. Each said "comes back
without waiting" by measuring time.Since(start) against a bound (50ms,
500ms, 1s, 2s, 3s) that a loaded runner can pass and so make red without
the guarantee breaking. Each now holds the slow thing until it has its
answer, so a call that comes back at all came back without waiting for it.
A deadline is kept only so a call that did wait fails as a FAIL rather
than a hang, and each is short of the slow thing's own timeout, so a call
that waited cannot come back in time by having it time out:

- cli_identity_test TestCLIIdentityFirstAskBounded: both looks run while
  the ask is held (it was already). The second look is run with firstAsk
  set to an hour, so a second look that waited again (not only waited the
  whole ask) is caught; 10s guard.
- claude_status_test TestClaudeIdentityServedWhileAsked: the stand-in CLI
  now waits for a file instead of `sleep 1`, and writes another when
  reached. The stale look must come back while it is held, with the ask
  still in flight (claudeStatusBusy), and the CLI must have been asked
  again. The guard is 4s, short of askClaudeStatus' own 5s kill. Its
  cleanup lets the CLI go and waits for the ask to end.
- partners_test TestPartnersDoesNotWait: the five Partners() calls run
  while the site is held; 10s guard (the fetch's own is 20s).
- partners_test TestPartnersNow and plugin_icon_test
  TestRepoIconsWaitForFirstFetch had a floor and a ceiling. The floor is
  the guarantee that the call waited for its bound, and a busy machine only
  lengthens it, so it stays (100ms, and 250ms for a 300ms wait as before).
  The ceiling was the "doesn't wait past its bound" half: it is now that
  the call comes back while the site/fetch is held; 10s guard (the fetch's
  own are 20s and 30s).
- sub2api_usage_test TestKeyAllowanceNeverWaits: the ten looks run while
  sub2api is held and report back over a channel, not t.Errorf from a
  goroutine that could outlive a failed test; 10s guard (the read's own is
  30s).

What was run (temp HOME, caches pinned):
  go test -tags nogui -race -count=10 -run '<the six tests>' ./internal/provider  ok
  go test -tags nogui -count=1 ./internal/provider                                ok 395.6s
  gofmt -l; go vet, GOOS=linux and GOOS=windows go vet -tags nogui ./internal/provider  clean

Broken by hand, each red at the new assertion:
  cli_identity.go, drop c.waited = true (every look waits):
    :124 a second look waited
  cli_identity.go, drop the firstAsk case (the first look waits the ask):
    :116 the first look waited for the held ask
  account.go, askClaudeStatus() in the stale case under the lock:
    claude_status_test.go:111 a stale look waited for the held CLI
  partners.go, Partners runs refreshPartners in line:
    :246 Partners waited for the held site
  partners.go, PartnersNow without its time.After(wait):
    :316 PartnersNow waited past its bound for the held site
  key_allowance.go, KeyAllowance reads in line (lock let go around it):
    sub2api_usage_test.go:279 a look waited for the held read
  plugin_icon.go, RepoIcons without its timer case:
    :168 RepoIcons waited past its 300ms for the held fetch
2026-10-11 22:02:50 +08:00
yetone 52f6b3a3ab plugins: the GitHub list waits up to 3s for a repository's https icon fetched the first time (yetone: 非官方插件显示不出来 logo)
RepoIcons starts every fetch, then waits for those not in yet, so the
list's first answer has them; one slower than the wait shows the next
time. The fetch takes fetchPluginIcon before its goroutine starts.

Ran: go test ./internal/provider ./internal/gui; the new test -race
-count=10, and red with a 1ns wait. A sandbox build (fresh HOME, real
GitHub): the first /api/plugins/github answer has all 8 icons the 13
tagged repositories give, screenshot in light and dark.
2026-10-10 05:22:07 +08:00
yetone a2714f7506 claude: a Claude account's usage resets are read in the zone /usage names on Windows too, and the provider tests pass whole on Windows (goal: 插件订阅 provider 跟内置的所有逻辑都要一模一样, run on Windows and Linux) — Windows has no time zone database, so "resets Oct 1 at 3:30pm (Asia/Shanghai)" was read in the machine's own zone, hours off for anyone not in that zone; magpie now carries the database (time/tzdata). The provider tests set HOME but not USERPROFILE, which Windows takes the home from, so on Windows they read the test box's own agent sign-ins (Gemini models in a list, an extra provider, a Cursor version); every test home sets both now. Tests whose fake CLI is a shell script (Claude Code's auth status, codex --version, macOS's security) skip on Windows, as the fake devin did, and file mode bits go unchecked there. TestParseClaudeUsage fails on Windows without the change. On Windows and on Linux (WSL) the provider package passes whole, three times on Windows (15 failed before), the plugin package and the move/plugin/Grok/Devin/usage tests five times over on Linux. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 13:51:24 +08:00
yetone 4ba51bb627 plugin: a plugin names its own icon and the key field's title and hint (Lemon on Discord) — a plugin's provider took only the market's icon, and an api method's key field always read "<name> API key" with no hint. auth.icon (or package.json "magpie": {"icon"}) as an https URL, fetched once through the public-only icon path, or a data:image URI now comes before the market icon; an api method's label titles the key field as in OpenCode, and a new placeholder hints it, in the window and in magpie plugin login. README has a For plugin authors section. TestPluginOwnIcon, TestPluginOwnIconAndKeyHint and plugin-key-hint.test.cjs (Chromium, WebKit, en/zh) fail without the change. 2026-10-01 11:42:45 +08:00