1 Commits
Author SHA1 Message Date
only-cli 5657d60771 test: cover the day cache and cli dispatch directly
cache.js had no test importing it, and cli.js was tested only through its
auth commands. Both now have a file of their own.

tests/cache.test.js proves the policy the module's comment states: a miss
fetches, parses, and writes under host and extension; a fresh copy is served
from disk without touching the network; a copy older than a day is refetched
and replaced; a body the parser rejects is never written, and a stale good
copy survives such a refetch; a cache directory that cannot be created costs
only the refetch. The network is a local proxy that records what it sees, so
"never asked" is asserted, not assumed.

tests/cli.test.js spawns the real binary against a throwaway OC_HOME with a
page seeded straight into a session file, so read, next, find, and do on
text all have something to answer with and nothing fetches. It covers help
on no command and both help flags, the help text naming every dispatchable
command once, unknown first words, a site name reaching the shortcut
resolver before being called unknown, budget and session name validation
running before any command, the nothing-open message from every session
command, the usage lines of open, raw, read, find, and do, do on a text
number reading in place with a recording proxy proving no request left, the
four planned commands failing with one line that names themselves, sites,
and flags placed before or after the command.

Each test was checked against a deliberate break in the code it guards.
2026-09-02 10:38:28 -04:00