Files
codewhale/crates
Hunter Bown 9ba42f0995 test: stop provider_switch test from clobbering user settings.toml
`provider_switch_clears_turn_cache_history` in `tui/ui/tests.rs`
calls `switch_provider(..., ApiProvider::Ollama, ...)`, which
internally persists the new provider via `Settings::save()` —
writing `default_provider = "ollama"` to
`~/Library/Application Support/deepseek/settings.toml` (or its
`dirs::data_dir()` equivalent on Linux/Windows). Because the
test's `create_test_app` did not isolate `HOME` / `USERPROFILE`,
each run silently overwrote the developer's real preferences.
The contamination then leaked back into adjacent picker tests:
`model_picker::tests::arrow_keys_move_within_focused_pane`
became order-sensitive, passing when it happened to run before
`provider_switch_clears_turn_cache_history` and failing after,
because Ollama is a pass-through provider and
`ModelPickerView` then hid the DeepSeek model rows.

Two fixes:

* `tui/ui/tests.rs::provider_switch_clears_turn_cache_history`
  now wraps the test in a `HomeGuard` that redirects HOME /
  USERPROFILE to a tempdir for the test's lifetime and restores
  the original values on drop. The guard owns the
  `test_support::lock_test_env()` mutex so clippy's
  `await_holding_lock` lint stays quiet through the
  `.await` (the pattern mirrors `tools::recall_archive::HomeGuard`).
* `tui/model_picker.rs::create_test_app` now also pins
  `app.api_provider = ApiProvider::Deepseek` alongside the
  existing `app.model` / `app.reasoning_effort` overrides, so
  the picker tests stop depending on whatever `default_provider`
  happens to be in the developer's `settings.toml` for any other
  reason.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 17:50:36 -05:00
..