CLI tests: cover data-directory override and platform fallback rules
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 82/100
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
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:
data_dirand the platform resolvers implement override precedence, empty-override rejection, and OS defaults.- The existing tests cover path joining rather than these decisions.
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_DIRtakes precedence over platform defaults, including when those default environment variables are absent. Include a path containing spaces and comparePathBufvalues rather than hard-coded separators. - An explicitly empty
SOTTO_DATA_DIRreturns 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 resolvesAPPDATA/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_HOMEwins; relative, empty and absent XDG values fall back toHOME/.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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from getsotto/sotto
-
Backups are staleOpenbackup-alert
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Web: show when a pending email verification request expiresPossibly taken @manosm19-netizen claimed this today. Openenhancement good first issue help wanted
Difficulty 2/5 Half a day Newbie friendliness 72/100
getsotto/sotto#827 · 1 comment ·
Maintainers usually reply within 1 day
-
TUI tests: verify binary secret edit rejection preserves stored bytesPossibly taken @dbdefault claimed this today. Opengood first issue help wanted test-coverage
Difficulty 2/5 3-5 days Newbie friendliness 62/100
getsotto/sotto#825 · 2 comments ·
Maintainers usually reply within 1 day
-
Docs: explain listing secret names and the ls JSON outputPossibly taken @Mohamedajab claimed this today. Opendocumentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 94/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area:ui
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openfootmanager/openfootmanager#1365 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
JackMechem/marbble#305 ·
Maintainers usually reply within 1 day