Add tests to ensure that source and target must not be the same repository · Entire
Add tests to ensure that source and target must not be the same repository
Summary of changes:
internal/validation/validation.go— addedValidateEndpoints(sourceURL, targetURL)that rejects identical (whitespace-trimmed) URLs and ignores empties so the existing "missing URL" errors stay specific.internal/syncer/syncer.go—newSessionnow callsValidateEndpointswhen a target is required, before any network I/O.internal/validation/validation_test.go—TestValidateEndpointscovers same/different/whitespace/empty/trailing-slash cases.internal/syncer/syncer_test.go—TestPublicAPIRejectsIdenticalSourceAndTargetprovesRun,Bootstrap, andProbe-with-target all reject same URLs;TestProbeWithoutTargetIgnoresEndpointEqualityCheckguards against false positives when probe has no target.
For --prune add negative tests
Committed as 834619c on changes:
- Proving
--branch main --pruneand--map main:stable --prunepreserve unrelated target branches.
GPG signing issue:
Register an empty config plugin empty.go via Register(ConfigLoader(), func() ConfigSource { return config.NewEmpty() }) to remove settings such as gpgsign from both global and system levels.
What I added:
internal/planner/planner_test.go:TestBuildPlansPrunePreservesUnrelatedBranchesUnderFilterandTestBuildReplicationPlansPrunePreservesUnrelatedBranchesUnderFilter. Both are table-driven over the two scenarios (--branch mainand--map main:stable) and prove the prune-scoping rule directly at the planner layer.internal/syncer/integration_test.go:TestRun_IntegrationPrunePreservesUnrelatedTargetBranchUnderFilter— end-to-end via the realRunpipeline against smart-HTTP servers. First sync seeds the target, then areleaseorphan is added, then the filtered--prunerun must leave it intact.
On the gpgSign disable:
Committed as d4cca23:
- Moved init() from
internal/syncertest/plugin.goto a dedicated production package, cleaner placement.
Integration Tests:
- Added
TestRun_IntegrationSyncPruneDeletesOrphanedBranchto confirm orphan deletion and preservation of branch during sync withPrune: true.
New Test Assertions:
- When
--tagsis unset, sync's--pruneonly operates on branches, preserving tags created after the prior sync. - Added
TestRun_IntegrationSyncPruneTagsPreservesTagCreatedDuringSyncto check tag preservation during sync.
Commit Summary:
- Managed incremental push failures and recovery in
TestRun_IntegrationIncrementalPushFailureRecoversOnRetry.