CLI tests: cover data-directory override and platform fallback rules

Open
#820 1 comment 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@vyb2306697 is already working on this.

Since Nov 8, 2026.

  • #821 by @vyb2306697 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
82/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli, testing

Research direction

Read crates/cli/src/paths.rs, starting with data_dir, the platform resolvers, and the existing tests. Add deterministic tests using explicit inputs or isolated child processes for override precedence, empty overrides, and each platform’s fallback rules; compare PathBuf values. Done means the acceptance cases pass without changing path-selection policy, and cargo fmt --all --check passes.

Written by the indexing model from the issue text.

Description

good first issue help wanted test-coverage

The problem

The CLI chooses where to keep its local store, saved settings and themes using SOTTO_DATA_DIR or platform-specific environment variables. The resolver contains important precedence and fallback rules, but the tests in paths.rs only check joining store.db and themes onto a supplied directory.

Add focused regression tests for directory resolution itself. This is a coverage gap, not a report that the current resolver selects the wrong path.

Evidence and starting point

Source-inspected on clean main at f237135bb41373f89076f66d89175263df0e33f0 on macOS:

A search of CLI Rust sources found no direct tests for platform_data_dir, the empty-override error, or XDG absolute-path selection. Existing integration tests use data-directory overrides for isolation, but that does not establish the fallback behaviour. Open/closed issues and open PRs were checked for overlap. Rust tests were not executed for this issue.

Acceptance criteria

  • A non-empty SOTTO_DATA_DIR takes precedence over platform defaults, including when those default environment variables are absent. Include a path containing spaces and compare PathBuf values rather than hard-coded separators.
  • An explicitly empty SOTTO_DATA_DIR returns the existing input error instead of falling back or resolving to the working directory.
  • With the override absent, macOS resolves HOME/Library/Application Support/sotto; Windows resolves APPDATA/sotto. Missing required variables produce the existing resolution error. Gate platform-specific expectations appropriately.
  • On the existing non-macOS/non-Windows branch, an absolute XDG_DATA_HOME wins; relative, empty and absent XDG values fall back to HOME/.local/share/sotto. Include absolute XDG with HOME absent, and failure when neither a usable XDG value nor HOME is available.
  • Tests are deterministic and do not race other tests by mutating process-wide environment variables. Use isolated child processes or a small pure resolution helper with explicit inputs, following existing repository patterns where applicable.
  • Tests do not initialise a vault, access the OS keychain, create files in the user's real data directory or require any real credentials.

Scope and validation

Preserve existing path-selection policy. In particular, do not introduce a new absolute-path requirement for SOTTO_DATA_DIR, migrate stored data or change the platform defaults. A small internal extraction solely to test the existing decisions is acceptable; a new configuration subsystem is not needed.

Run the focused tests and cargo fmt --all --check. State which platform branches were executed locally and rely on the corresponding supported CI runners for platform-specific coverage rather than claiming one OS exercised every branch.

This is a focused first contribution with an existing, short implementation to use as the contract. Follow CONTRIBUTING.md, including DCO sign-off (git commit -s).

Dominant language
Rust
Stars
31
Forks
42
Avg merge
3d 21m
Merged PRs (30d)
147

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsotto/sotto

All issues in getsotto/sotto

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.