Skip to content
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
mainfrom
claude/practical-mclean-406140
Closed

test: make config default tests hermetic against host config#216
joestump wants to merge 1 commit into
mainfrom
claude/practical-mclean-406140

Conversation

@joestump

Copy link
Copy Markdown
Owner

Problem

go test ./internal/config/ fails on any developer machine that has a real
msgbrowse config file installed:

--- FAIL: TestLoadDefaults
    config_test.go:29: LLM.ChatModel = "gpt-oss:120b", want local-first default local-chat
    config_test.go:32: LLM.EmbedModel = "text-embedding-3-large", want local-first default local-embed

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 actual config.yaml, whose
chat_model/embed_model override the code defaults the test asserts. The test
therefore passes only on machines with no installed config (e.g. CI).

Fix

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. All
three Load("") call sites (TestLoadDefaults, TestEnvOverride,
TestValidate) go through it.

This mirrors the hermetic-HOME approach used for the setup detection tests in
7cbbe3a (#214). save_test.go already uses Load(path) with an explicit temp
path, so it needed no change.

Verification

  • go test ./internal/config/ and go vet ./internal/config/ — clean.
  • Reproduced the exact reported failure to confirm the fix addresses the cause,
    not just the symptom: with the HOME/XDG overrides temporarily removed and
    HOME pointed at a fake tree containing a config.yaml setting
    chat_model: gpt-oss:120b / embed_model: text-embedding-3-large,
    TestLoadDefaults failed 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 @joestump by Claude.

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>
@joestump

Copy link
Copy Markdown
Owner Author

Superseded by the canonical Gitea PR: https://gitea.stump.rocks/stump.wtf/msgbrowse/pulls/247

The head commit was pushed to gitea.stump.rocks/stump.wtf/msgbrowse unchanged and the PR reopened there against main. Nothing from this branch is lost — the commit SHA is identical.

msgbrowse now develops on Gitea; stump.wtf/msgbrowse is the source of truth, push-mirrored to https://github.com/stump-wtf/msgbrowse. This personal repo is being archived.

🤖 Posted on behalf of @joestump by Claude.

@joestump joestump closed this Jul 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant