Skip to content

test: cover the replication entrypoints offline (#10) - #16

Merged
vmvarela merged 1 commit into
masterfrom
test/10-entrypoint-coverage
Oct 24, 2026
Merged

vmvarela merged 1 commit into
masterfrom
test/10-entrypoint-coverage

Conversation

@vmvarela

Copy link
Copy Markdown
Owner

What

Add automated, offline coverage for the three replication entrypoints that had none: run, preflight and syncGit.

Production code changes are limited to two seams that keep the default behaviour identical:

  • newSide is now a package variable wrapping newSideFromAccounts, so run can be driven with fake sides.
  • gitRemote(owner/repo) centralises the URL used by the bare clone and the replicate-target remote; it still returns https://github.com/<owner/repo>.git.

Why

The issue reported run and syncGit at 0.0% and preflight at 58.1% on bbe03ae. 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: git work repo cloned to a bare source, an empty bare destination and httptest servers 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-run push 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 executable pre-receive hook that exits 1 makes syncGit fail with push refs and leaves the destination untouched.
  • TestSyncGitClonesAndPushesRefs: direct success path asserting branch and tag SHAs.

Validation on this branch:

  • gofmt -l .: no output
  • go vet ./..., go build ./...: pass
  • go test -race -count=1 ./...: 48 tests pass
  • Coverage: run 0.0% → 81.8%, syncGit 0.0% → 71.4%, preflight 58.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 access
  • git diff --check: clean

Remaining work

preflight remains 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

@vmvarela
vmvarela merged commit c354c90 into master Oct 24, 2026
9 checks passed
@vmvarela
vmvarela deleted the test/10-entrypoint-coverage branch October 24, 2026 10:40
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.

Cover the replication entrypoints with automated integration tests

1 participant