Add tests for internal/storage — the backend abstraction has zero coverage #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?
internal/storageis the pluggable storage backend the README headlinesat :51, and it has no test files at all.
Source files with zero coverage:
storer.go,s3.go,file.go,rclone.go,url.go,module.go.url.go(142 lines) parsess3://,file://, andrclone://URLsincluding query parameters, and decides which backend gets constructed.
A parsing bug there silently sends backups to the wrong destination. It
has no unit test.
README:466-468 already flags "Storage backend coverage tests… the rclone
path is the least exercised in CI". In fact none of the three backends is
exercised at this layer.
Definition of done
internal/storagehas table-driven tests for URL parsing covering, atminimum: each of the three schemes; query-parameter handling; missing
or malformed components; an unknown scheme; and the exact backend type
selected for each valid input. Assert on error cases, not just happy
paths.
file://backend: round-trip tests (put, get, list, delete, stat)against a temp directory via
t.TempDir(), including missing-key andoverwrite behavior.
s3://backend: tests against the existing S3 test harness used byinternal/s3(which has 445 test LOC — reuse it rather than inventinga new mock).
rclone://backend: at minimum, construction and argument-shapingtests that do not require a live rclone binary. If genuinely
untestable without the binary, say so explicitly in a comment and
cover what can be covered.
Storerinterface contract is exercised through a sharedconformance test that every backend runs, so a new backend inherits
coverage.
uncovers a real bug, file it separately and reference it here rather
than fixing it inline.
make checkgreen.