fix(test): make no-provider tests robust against real ~/.caseforge.yaml#71
Merged
Conversation
TestAskCommand_FailsWhenNoProvider and TestAskCommand_Integration_NoProvider were relying on env-var clearing, which doesn't work when ~/.caseforge.yaml has a real api_key (config file takes precedence over empty env vars in viper). - FailsWhenNoProvider: reset viper and set ai.provider=noop directly - Integration_NoProvider: pass --config pointing to a temp noop-provider yaml so initConfig() reads that instead of ~/.caseforge.yaml AT-235: same root cause — conformance --config <noop.yaml> forces the "LLM provider not available" path regardless of the local config file.
Reviewer feedback on #71: - TestAskCommand_Integration_NoProvider was leaving cfgFile set to a deleted temp path; subsequent rootCmd.Execute() calls in the same test binary printed "error reading config: no such file or directory" to stderr. Added cfgFile = "" to the cleanup closure. - AT-235 noprov config was written to /tmp and leaked across runs. Moved to $WORKDIR so the existing trap rm cleans it up automatically. - Switched '$NOPROV_CFG' (single-quotes inside double-quotes) to \"$NOPROV_CFG\" for idiomatic quoting consistency.
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
TestAskCommand_FailsWhenNoProviderandTestAskCommand_Integration_NoProviderwere flaky on machines with a real API key in~/.caseforge.yaml. Clearing env vars didn't help because viper loads the config file first, andapi_keyin the file takes precedence over empty env vars.conformance no LLM fails gracefully) had the same problem — the acceptance binary reads~/.caseforge.yaml.Fixes
TestAskCommand_FailsWhenNoProvider: callviper.Reset()+viper.Set("ai.provider", "noop")instead of relying on env var clearingTestAskCommand_Integration_NoProvider: pass--config <tmp-noop.yaml>soinitConfig()reads a controlled file instead of~/.caseforge.yamlnoopconfig yaml and pass it via--configflagTest Plan
go test ./cmd/... -run TestAskCommand -count=1— all 5 pass./scripts/acceptance.sh— AT-235 passes, zero other failures