Pin CLI error messages by driving their real call sites (closes #87) #117

Merged
clawbot merged 1 commits from issue-87-pin-cli-errmsgs into next 2026-10-03 18:24:31 +02:00
Collaborator

Pins the CLI's user-visible error messages by calling the function that emits each one and asserting on the full text it returns, replacing a test that rendered format strings copied from production. Closes #87.

  • internal/cli/errmsg_test.go: one test per message, each driving the real emitter (findManifest, verifyRequiredSigner, collectInputPaths, generateManifestOperation, the root command's action, openManifestReader, fetchManifestOperation, downloadFile, sanitizePath, finishDownload, verifyDownloadedHash) with EqualError plus ErrorIs on the sentinel. No production format string appears in a test file.
  • internal/cli/freshen_test.go: the scanned file's mtime is now the epoch, so reading an absent manifest mtime as the epoch would classify the entry unchanged and fail the test.

Mutations run:

  1. recordEntry restored to time.Unix(existing.GetMtime().GetSeconds(), int64(existing.GetMtime().GetNanos())), entryMtime untouched: TestFreshenRecordEntryMtimePresence fails.
  2. Each of the sixteen pinned messages reworded at its call site: every one fails its own test, the gpg-signed signer-mismatch case included.

Not visible in the diff:

  • The signer-mismatch test generates a throwaway gpg key and skips where gpg is absent, like the other signing tests.
  • run only logs the unknown-command error, so that test lets run build the app with no command, then runs the same app on bogus to get the error value.

Disclosure: sanitizePath's second absolute-path return is not pinned separately; on Unix, cleaning a relative path never yields an absolute one, so it is unreachable there.

Model: opus-4-8 (first implementation); opus-5-5 (completion, this text)

Pins the CLI's user-visible error messages by calling the function that emits each one and asserting on the full text it returns, replacing a test that rendered format strings copied from production. Closes https://git.eeqj.de/sneak/mfer/issues/87. - `internal/cli/errmsg_test.go`: one test per message, each driving the real emitter (`findManifest`, `verifyRequiredSigner`, `collectInputPaths`, `generateManifestOperation`, the root command's action, `openManifestReader`, `fetchManifestOperation`, `downloadFile`, `sanitizePath`, `finishDownload`, `verifyDownloadedHash`) with `EqualError` plus `ErrorIs` on the sentinel. No production format string appears in a test file. - `internal/cli/freshen_test.go`: the scanned file's mtime is now the epoch, so reading an absent manifest mtime as the epoch would classify the entry unchanged and fail the test. Mutations run: 1. `recordEntry` restored to `time.Unix(existing.GetMtime().GetSeconds(), int64(existing.GetMtime().GetNanos()))`, `entryMtime` untouched: `TestFreshenRecordEntryMtimePresence` fails. 2. Each of the sixteen pinned messages reworded at its call site: every one fails its own test, the gpg-signed signer-mismatch case included. Not visible in the diff: - The signer-mismatch test generates a throwaway gpg key and skips where gpg is absent, like the other signing tests. - `run` only logs the unknown-command error, so that test lets `run` build the app with no command, then runs the same app on `bogus` to get the error value. Disclosure: `sanitizePath`'s second absolute-path return is not pinned separately; on Unix, cleaning a relative path never yields an absolute one, so it is unreachable there. Model: opus-4-8 (first implementation); opus-5-5 (completion, this text)
clawbot added the needs-review label 2026-10-03 16:12:21 +02:00
clawbot self-assigned this 2026-10-03 16:12:21 +02:00
Author
Collaborator

Review passed.

  • Deviation: gated on this branch rebased onto the current next, with the TODO.md conflict resolved by keeping every entry, this PR's on top; that rebase still has to be pushed before merge.
  • Judgement call: the branch commit is authored under the owner's git identity rather than clawbot; not treated as blocking.

Model: opus-5-5

Review passed. - Deviation: gated on this branch rebased onto the current `next`, with the `TODO.md` conflict resolved by keeping every entry, this PR's on top; that rebase still has to be pushed before merge. - Judgement call: the branch commit is authored under the owner's git identity rather than `clawbot`; not treated as blocking. Model: opus-5-5
Author
Collaborator

Review passed.

  • Gated on next at a3749e9, with this branch rebased onto it and the TODO.md conflict resolved by keeping every entry, this PR's on top; that rebase still has to be pushed before merge.
  • Judgement call: the second absolute-path return in sanitizePath stays unpinned, as the PR body says; it cannot be reached on Unix.
  • Judgement call: the branch commit is authored under the owner's git identity rather than clawbot; not treated as blocking.

Model: opus-5-5

Review passed. - Gated on `next` at `a3749e9`, with this branch rebased onto it and the `TODO.md` conflict resolved by keeping every entry, this PR's on top; that rebase still has to be pushed before merge. - Judgement call: the second absolute-path return in `sanitizePath` stays unpinned, as the PR body says; it cannot be reached on Unix. - Judgement call: the branch commit is authored under the owner's git identity rather than `clawbot`; not treated as blocking. Model: opus-5-5
clawbot added 1 commit 2026-10-03 18:11:38 +02:00
errmsg_test.go now calls the function that emits each user-visible CLI
error message and asserts on the full text it returns, instead of
rendering format strings copied from production, so rewording any pinned
message fails the suite. The unknown-command message is driven through
the root command's action.

The signer-mismatch case signs a manifest with a throwaway gpg key and
is skipped where gpg is absent, like the repo's other signing tests.

The freshen mtime-presence test gives the scanned file an epoch mtime,
so it fails if recordEntry reads an absent manifest mtime as the epoch.

Model: opus-4-8 (first implementation); opus-5-5 (completion, this message)
clawbot force-pushed issue-87-pin-cli-errmsgs from 1b37f945ca to c015956559 2026-10-03 18:11:38 +02:00 Compare
clawbot merged commit c31796998f into next 2026-10-03 18:24:31 +02:00
clawbot deleted branch issue-87-pin-cli-errmsgs 2026-10-03 18:24:31 +02:00
Sign in to join this conversation.