Skip to content

Test BackupService's failed-update and relative-directory paths - #74

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/backup-service-update-failure-tests
Nov 16, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/backup-service-update-failure-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle for BackupService, with no production code changed.

  • testBackupUserRepositories_ExistingDirectoryThatIsNotARepositoryFailsToUpdate: when a repository's directory already exists but is not a Git repository, the update fails ( ✗ Failed to update: … and Failed to backup repo1: Failed to update repository on standard error). The directory is not cloned over, its contents are left untouched, the other repository is still cloned, and the thrown summary names only repo1. Before this test, no test ran the IOException branch of backupRepository's update path.
  • testBackupDirectory_RelativePathIsResolvedAgainstWorkingDirectoryAndNormalized: a relative backup.directory containing .. is resolved against the working directory and normalized, as shown by the exact path showBackupStatus prints. The existing testBackupDirectory_IsAbsolute only asserts that nothing is thrown. It was left unchanged and the new test was added beside it.
  • Adds a captureStderr helper, written to match the existing captureStdout.
  • CHANGELOG.md [Unreleased] → Added entry.

Before this cycle, a documentation accuracy sweep (Stage A) was run. CONFIG.md, COMMANDS.md, USER_GUIDE.md and README.md were checked against application*.properties, BackupCommandLineRunner, BackupController, BackupService, ScheduledBackupService, GitHubService and TraceInstallId, and no drift was found. For that reason, the cycle was spent on test expansion instead.

Test plan

  • mvn test -Dtest=BackupServiceTest: 29 tests run, 0 failures
  • mvn test: 230 tests run, 0 failures, 0 errors, 1 skipped (the same skip as on main), BUILD SUCCESS
  • CI Build green on the PR head

Skipped issues

No tracking issue: this test-coverage gap was found during triage.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

A repository directory that exists but is not a Git repository is
reported as a failed update without being cloned over, and a relative
backup.directory is resolved and normalized. Neither was asserted by
any test before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (scored against the diff and the CI run on the PR head):

  • Scope: PASS — only BackupServiceTest.java (+54) and one CHANGELOG.md line are changed; no production code is touched.
  • Tests-new: PASS — no new public method is added. The new captureStderr helper is used by the new failed-update test.
  • Tests-fix: N/A — this is a characterization-only change, so there is no fix to stash and revert. The relative-path test would fail if the toAbsolutePath().normalize() in the BackupService constructor were removed (the .. assertion and the exact-path comparison). The failed-update test would fail if the IOException catch in backupRepository stopped reporting ✗ Failed to update or stopped rethrowing.
  • Sibling structure: PASS — the method names follow test<MethodName>_<Scenario>, the tests use @TempDir and mocked GHRepository/GitHubService, and captureStderr mirrors captureStdout line for line.
  • Sibling renames: N/A — nothing is renamed.
  • Docs: PASS — no behavior changes. CHANGELOG.md [Unreleased] → Added records the tests, following the precedent of the earlier test-only entries.
  • Issue resolution: N/A — no Closes. The gap was found during triage. README links to a LICENSE file that does not exist #8 is deferred because choosing a license is the maintainer's decision.
  • CI: PASS — build and docker-build are both green on the head commit (run 43794759467). Locally, mvn test ran 230 tests with 0 failures and 1 pre-existing skip.
  • Config-doc parity / Command-doc parity: N/A — no properties, flags or endpoints are added.
  • Package placement: PASS — the test stays at its mirrored path, src/test/java/com/github/backup/.
  • No credential leakage: PASS — the tests read and print no token.

Observations (judgment calls, none blocking):

  • src/test/java/com/github/backup/BackupServiceTest.java (testBackupUserRepositories_ExistingDirectoryThatIsNotARepositoryFailsToUpdate) — the test depends on JGit's Git.open not finding a repository in any parent of @TempDir. JGit's lenient FileKey lookup checks only the directory itself and its .git, so this holds wherever the temp directory lives.
  • testBackupDirectory_IsAbsolute now duplicates the new, stronger relative-path test. It was left in place so that no existing test was removed in a coverage-expansion cycle. It can be deleted in a later cleanup.
  • The current behavior is arguably a usability gap: a stray non-repository directory with a repository's name fails on every run, and the message does not say why. It is documented here as current behavior rather than changed under a test-only cycle.

This review was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson

Copy link
Copy Markdown
Member Author

Correction to the last observation in the self-review above: the reason is reported. JGit's Git.open throws RepositoryNotFoundException (repository not found: <path>), and ✗ Failed to update: repository not found: <path> prints that message. Only the later Failed to backup repo1: Failed to update repository line, and so the thrown summary, leave the cause out. No issue was filed for it. Readers of the console output still see the cause on the line just above.

This comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 33167c1 into main Nov 16, 2026
2 checks passed
@dmccoystephenson
dmccoystephenson deleted the feature/backup-service-update-failure-tests branch November 16, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant