This repository was archived by the owner on Jul 25, 2026. It is now read-only.
test: make config default tests hermetic against host config#216
Closed
joestump wants to merge 1 commit into
Closed
test: make config default tests hermetic against host config#216joestump wants to merge 1 commit into
joestump wants to merge 1 commit into
Conversation
TestLoadDefaults asserts the local-first defaults (llm.chat_model=local-chat,
llm.embed_model=local-embed), but config.Load("") adds real host search paths
(., $HOME/.config/msgbrowse, os.UserConfigDir()/msgbrowse), so ReadInConfig
picked up the developer's own config.yaml and its chat_model/embed_model
overrode the code defaults — the test passed only on machines with no installed
config.
Add a loadHermetic(t) helper that points HOME and XDG_CONFIG_HOME at an empty
t.TempDir() before Load(""), so the file search finds nothing and the built-in
defaults are exercised regardless of what's installed on the host. Route the
three Load("") call sites (TestLoadDefaults, TestEnvOverride, TestValidate)
through it.
Mirrors the hermetic-HOME fix for the setup detection tests (7cbbe3a, #214).
Verified by pointing HOME at a fake tree with a config.yaml setting
chat_model: gpt-oss:120b / embed_model: text-embedding-3-large (the exact values
from the bug report): the old code reproduced the reported failure, the new code
passes.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Superseded by the canonical Gitea PR: https://gitea.stump.rocks/stump.wtf/msgbrowse/pulls/247 The head commit was pushed to msgbrowse now develops on Gitea; 🤖 Posted on behalf of |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
go test ./internal/config/fails on any developer machine that has a realmsgbrowse config file installed:
config.Load("")adds real host search paths —.,$HOME/.config/msgbrowse,and
os.UserConfigDir()/msgbrowse(macOS:~/Library/Application Support/msgbrowse)— so
ReadInConfig()picks up the developer's actualconfig.yaml, whosechat_model/embed_modeloverride the code defaults the test asserts. The testtherefore passes only on machines with no installed config (e.g. CI).
Fix
Add a
loadHermetic(t)helper that pointsHOMEandXDG_CONFIG_HOMEat anempty
t.TempDir()beforeLoad(""), so the file search finds nothing and thebuilt-in defaults are exercised regardless of what's installed on the host. All
three
Load("")call sites (TestLoadDefaults,TestEnvOverride,TestValidate) go through it.This mirrors the hermetic-
HOMEapproach used for the setup detection tests in7cbbe3a (#214).
save_test.goalready usesLoad(path)with an explicit temppath, so it needed no change.
Verification
go test ./internal/config/andgo vet ./internal/config/— clean.not just the symptom: with the
HOME/XDGoverrides temporarily removed andHOMEpointed at a fake tree containing aconfig.yamlsettingchat_model: gpt-oss:120b/embed_model: text-embedding-3-large,TestLoadDefaultsfailed with the identical assertions from the bug report;the hermetic version passes even with that same host config present.
Test-only change; independent of the onboarding MOV-warning fix on
claude/mov-converter-errors-52b465.🤖 Generated with Claude Code
🤖 Posted on behalf of
@joestumpby Claude.