Add real end-to-end tests for the freshen and fetch commands #66
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?
Context
freshenhas no test at all.internal/cli/freshen_test.gocontainsTestFreshenUnchangedandTestFreshenWithChanges, but neither ever callsfreshenManifestOperationorfreshenCommand. The file says so out loud atinternal/cli/freshen_test.go:66-67:grepforfreshenManifestOperationacross all_test.gofiles returnsnothing. These tests assert that the fixture was built correctly and then
stop. They pass whether or not
freshenworks, which makes them worse thanno test — they show up as green coverage for a command that is entirely
unverified.
fetchis only half tested.internal/cli/fetch_test.gohas four tests(
TestFetchFromHTTP,TestFetchHashMismatch,TestFetchSizeMismatch,TestFetchProgress) which all calldownloadFile()directly against anhttptest.Server. That covers the download primitive well, but nothingcalls
fetchManifestOperationorfetchCommand, so manifest resolution,iteration over entries, directory creation, resume behavior, and the
command's exit codes are untested.
Definition of done
freshenis tested end-to-end throughfreshenManifestOperation(or thecommand entry point): build a tree, generate a manifest, then verify each
of — no changes leaves the manifest semantically unchanged; a modified
file updates its hash and size; a new file is added; a deleted file is
removed; the manifest on disk is rewritten correctly and reloads.
internal/cli/freshen_test.go:66-67is gone,along with any assertion that only checks fixture setup.
fetchis tested end-to-end throughfetchManifestOperation(or thecommand entry point) against an
httptest.Serverserving a realgenerated manifest plus its files: all files land with correct content,
nested directories are created, a hash mismatch fails the command with a
non-zero exit, and a partially-present destination resumes or re-fetches
per the documented behavior.
make testtimeout and uset.TempDir().make checkpasses.TODO.mdupdated in the same commit.Implementation requirements
real assertions, or add alongside and remove the placeholders explicitly.
httptest.Serveronly.these must not skip when gpg is absent.
manifest, exit codes. Do not assert on log text as a proxy for behavior.
freshenorfetch—which is likely, given neither has ever been exercised — do not paper over
them to get green. File each as its own issue, reference it from the PR,
and mark the failing case
t.Skipwith the issue number only if fixing itin the same PR would balloon the scope. Fixing it in place is preferred.
(closes #66).