Skip to content

Injectable filesystem roots for core::paths to unit-test first-run flows #461

Description

@LargeModGames

Is your feature request related to a problem? Please describe.

The first-run selected-source path has no unit coverage and cannot safely get any today. Everything past the source picker in core/first_run.rs (apply_selections) persists immediately through the real config/state directories: ClientConfig::init_default_spotify_config(), UserConfig::save_config(), and core::state::save(default_state_path()?, ...) all resolve their locations through core::paths, which reads process env (XDG_*). Repo tests deliberately never mutate process env (one process, shared threads), so any test driving this path would write into the developer's actual config directory. Raised during review of #460.

Describe the solution you'd like

Injectable filesystem roots in core::paths (explicit root parameters or a test-only override), so config/state/cache locations can be pointed at a tempdir per test. On top of that:

  • extend ScriptedOnboarding (core/test_helpers.rs) with configurable pick_sources output (it currently always returns None);
  • add regression tests through run_first_run_picker for free-only and Spotify-plus-free selections, covering client.yml seeding, active-source persistence, and per-source setup.

Describe alternatives you've considered

  • Setting XDG_* env vars inside tests: rejected, env is process-global and tests share threads.
  • Extracting more of the flow into pure functions: helps, but the persistence half stays unverified without redirectable paths.

Additional context

Discussion: #460 (comment)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions