Isolate skills client discovery in default-client test#5417
Merged
Conversation
TestNewDefaultClient stubbed the TOOLHIVE_API_URL env reader but let the server-discovery step run against real local state. When a thv or Desktop server was running, discovery found it and returned its base URL, so the "falls back to default URL" and "applies options" subtests saw the discovered URL instead of the default and failed. CI passed only because no server is running there. Inject the discovery step into newDefaultClientWithEnv, mirroring the existing env.Reader injection, and have the subtests stub it. Each resolution step (env var, discovery, default fallback) is now tested in isolation, and a new subtest covers the discovered-server path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5417 +/- ##
==========================================
+ Coverage 68.76% 68.79% +0.02%
==========================================
Files 629 629
Lines 63922 63922
==========================================
+ Hits 43958 43976 +18
+ Misses 16707 16689 -18
Partials 3257 3257 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ChrisJBurns
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TestNewDefaultClientstubbed theTOOLHIVE_API_URLenv reader but let the server-discovery step run against real local state. When athv serveor Desktop server was running, discovery found it and returned its base URL (http://localhostfor a Unix socket), so the "falls back to default URL when env is empty" and "applies options" subtests saw the discovered URL instead ofhttp://127.0.0.1:8080and failed. CI passed only because no server runs there, making this a confusing local-only failure.newDefaultClientWithEnvalready injects anenv.Readerso the env-var step is testable; the discovery step just wasn't given the same treatment.discoverFuncparameter tonewDefaultClientWithEnv, mirroring the existingenv.Readerinjection.NewDefaultClientpasses the realresolveViaDiscovery; no production behavior change.Type of change
Test plan
task test)task lint-fix)Manual: ran
go test -count=1 -run TestNewDefaultClient ./pkg/skills/client/; all four subtests pass. The discovery step is now fully stubbed, so the test is robust to a running local server by construction.Does this introduce a user-facing change?
No. The change adds a test-injection seam;
NewDefaultClientbehaves identically.🤖 Generated with Claude Code