Add tests for the CLI (bin/quak.ts)
#12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
bin/quak.tsis 436 lines — the single largest file in the repo — and has zero tests. Notest file imports it. The repo's own README says tests are the canonical documentation and
that
mainis only green when the suite covers what ships, and the README documents a CLIcontract (exit codes,
--jsonoutput, session file permissions) that nothing verifies.Untested behaviour includes:
0600file mode and0700directory mode;get/get-thumbsearch-all-collections loops used when--collectionis omitted;--exif/--alloption handling onbackup-metadata;documents.
Definition of done
bin/quak.tsis testable without spawning a subprocess and without callingprocess.exitfrom inside async handlers — refactor the command bodies into functions that return or
throw, with a thin top-level wrapper that maps results to exit codes. The externally
visible CLI behaviour does not change.
whoami,logout,collections,files,get,get-thumb,backup, andhelper list-missing-thumbnails, each in both human and--jsonoutputmodes where the command supports
--json.per-file failures.
0600in a directory with mode0700,and that
logoutremoves it.get/get-thumbfind a file by ID across collections when--collectionisnot supplied, and report a clear error when the ID is not found anywhere.
mkdtempSyncfor temporary directories and inject a fake session directoryrather than touching the real one. No test writes to the developer's home directory.
script/test. If it doesnot, say so on this issue rather than raising the cap.
make checkgreen.TODO.mdupdated in the same commit.Note
process.exit()is currently called from nine places inside async handlers, which cantruncate pending stdout writes when output is piped. Item 1 fixes that as a side effect; call
it out explicitly in the PR body.