Repository navigation
test: cover the replication entrypoints offline (#10) - #16
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add automated, offline coverage for the three replication entrypoints that had none:
run,preflightandsyncGit.Production code changes are limited to two seams that keep the default behaviour identical:
newSideis now a package variable wrappingnewSideFromAccounts, soruncan be driven with fake sides.gitRemote(owner/repo)centralises the URL used by the bare clone and thereplicate-targetremote; it still returnshttps://github.com/<owner/repo>.git.Why
The issue reported
runandsyncGitat 0.0% andpreflightat 58.1% onbbe03ae. A regression in ordering, validation or dry-run handling could pass the suite and only surface during a real replication.How tested
New
entrypoint_test.go(335 lines), all fixtures local:gitwork repo cloned to a bare source, an empty bare destination andhttptestservers for the API.TestRunRejectsInvalidArguments: missing/extra arguments,..component, identical repositories, non-positive timeout and a non-github.com host; also asserts the seams are never touched.TestRunLeavesDestinationUntouchedWhenPreflightFails: a 404 on the source repository aborts before any write; destination refs are byte-identical and it only received GET requests.TestRunDryRunLeavesDestinationUntouched: full preflight plus--dry-runpush leaves destination refs unchanged, receives no mutating request and prints the dry-run confirmation.TestRunReplicatesIntoDestination: success path; destination branch and tag refs match the source and the metadata requests (PATCH repos/<target>,PUT .../topics,POST .../labels) are issued.TestSyncGitPropagatesRejectedPush: an executablepre-receivehook that exits 1 makessyncGitfail withpush refsand leaves the destination untouched.TestSyncGitClonesAndPushesRefs: direct success path asserting branch and tag SHAs.Validation on this branch:
gofmt -l .: no outputgo vet ./...,go build ./...: passgo test -race -count=1 ./...: 48 tests passrun0.0% → 81.8%,syncGit0.0% → 71.4%,preflight58.1% → 60.5%, total 69.7% → 79.9%HTTPS_PROXY=http://127.0.0.1:9 HTTP_PROXY=http://127.0.0.1:9 go test -count=1 ./...: 48 tests pass, so no test needs network accessgit diff --check: cleanRemaining work
preflightremains below 100% because HTTP and validation error branches inside it are out of scope for this issue. No dependency changes, so the vulnerability scan result is unchanged.Closes #10