#96 Add CLI tests for download overwrite and filename behavior

closed medium · sable · 2026-03-02 23:37 · closed 2026-03-02 23:37 · Phase 1: CLI Foundation

Comments — 1

sable note 2026-03-02 23:37

download.rs CLI wrapper has two behaviors worth testing: 1. Refuses to overwrite existing output file (bail with helpful message) 2. Defaults output path to the original filename from the record

These don't need MockTransport — they're filesystem-level checks. Use tempfile crate.

Test cases:

  • output_defaults_to_original_filename: mock the core call somehow, verify PathBuf logic
  • refuses_to_overwrite_existing_file: create a file, verify bail message includes the path

Note: testing these in isolation requires either extracting the file-write logic into a testable function or accepting that we test via the full Execute trait (which needs session/identity). Consider extracting a write_output(name, plaintext, output_override) -> Result<PathBuf> helper.

Generated 2026-03-03 02:53 UTC