MCPcopy Create free account
hub / github.com/entireio/git-sync / TestClientSyncEndToEndWithLocalRepos

Function TestClientSyncEndToEndWithLocalRepos

client_test.go:87–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestClientSyncEndToEndWithLocalRepos(t *testing.T) {
88 sourceRepo, sourceFS := syncertest.NewMemoryRepo(t)
89 syncertest.MakeCommits(t, sourceRepo, sourceFS, 1)
90 targetRepo, _ := syncertest.NewMemoryRepo(t)
91
92 sourceServer := newSmartHTTPRepoServer(t, sourceRepo)
93 targetServer := newSmartHTTPRepoServer(t, targetRepo)
94 defer sourceServer.Close()
95 defer targetServer.Close()
96
97 client := New(Options{})
98 result, err := client.Sync(context.Background(), SyncRequest{
99 Source: Endpoint{URL: sourceServer.RepoURL()},
100 Target: Endpoint{URL: targetServer.RepoURL()},
101 Scope: RefScope{Branches: []string{"master"}},
102 Policy: SyncPolicy{Protocol: ProtocolV1},
103 })
104 if err != nil {
105 t.Fatalf("client sync: %v", err)
106 }
107 if len(result.Refs) != 1 || result.Refs[0].Action != ActionCreate {
108 t.Fatalf("unexpected ref results: %+v", result.Refs)
109 }
110 if result.Counts.Applied != 1 {
111 t.Fatalf("applied = %d, want 1", result.Counts.Applied)
112 }
113
114 targetRef, err := targetRepo.Reference(plumbing.NewBranchReferenceName("master"), true)
115 if err != nil {
116 t.Fatalf("resolve target ref: %v", err)
117 }
118 sourceRef, err := sourceRepo.Reference(plumbing.NewBranchReferenceName("master"), true)
119 if err != nil {
120 t.Fatalf("resolve source ref: %v", err)
121 }
122 if targetRef.Hash() != sourceRef.Hash() {
123 t.Fatalf("target hash = %s, want %s", targetRef.Hash(), sourceRef.Hash())
124 }
125}
126
127func TestClientReplicateRejectsUnsupportedMode(t *testing.T) {
128 err := (SyncRequest{

Callers

nothing calls this directly

Calls 7

NewMemoryRepoFunction · 0.92
MakeCommitsFunction · 0.92
newSmartHTTPRepoServerFunction · 0.70
NewFunction · 0.70
CloseMethod · 0.65
SyncMethod · 0.45
RepoURLMethod · 0.45

Tested by

no test coverage detected