MCPcopy Index your code
hub / github.com/git-bug/git-bug / TestMerge

Function TestMerge

entity/dag/entity_actions_test.go:206–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

204}
205
206func TestMerge(t *testing.T) {
207 repoA, repoB, _, id1, id2, resolvers, def := makeTestContextRemote(t)
208
209 // SCENARIO 1
210 // if the remote Entity doesn't exist locally, it's created
211
212 // 2 entities in repoA + push to remote
213 e1A := New(def)
214 e1A.Append(newOp1(id1, "foo"))
215 err := e1A.Commit(repoA)
216 require.NoError(t, err)
217
218 e2A := New(def)
219 e2A.Append(newOp2(id2, "bar"))
220 err = e2A.Commit(repoA)
221 require.NoError(t, err)
222
223 _, err = Push(def, repoA, "remote")
224 require.NoError(t, err)
225
226 // repoB: fetch + merge from remote
227
228 _, err = Fetch(def, repoB, "remote")
229 require.NoError(t, err)
230
231 results := MergeAll(def, wrapper, repoB, resolvers, "remote", id1)
232
233 assertMergeResults(t, []entity.MergeResult{
234 {
235 Id: e1A.Id(),
236 Status: entity.MergeStatusNew,
237 },
238 {
239 Id: e2A.Id(),
240 Status: entity.MergeStatusNew,
241 },
242 }, results)
243
244 assertEqualRefs(t, repoA, repoB, "refs/"+def.Namespace)
245
246 // SCENARIO 2
247 // if the remote and local Entity have the same state, nothing is changed
248
249 results = MergeAll(def, wrapper, repoB, resolvers, "remote", id1)
250
251 assertMergeResults(t, []entity.MergeResult{
252 {
253 Id: e1A.Id(),
254 Status: entity.MergeStatusNothing,
255 },
256 {
257 Id: e2A.Id(),
258 Status: entity.MergeStatusNothing,
259 },
260 }, results)
261
262 assertEqualRefs(t, repoA, repoB, "refs/"+def.Namespace)
263

Callers

nothing calls this directly

Calls 14

makeTestContextRemoteFunction · 0.85
NewFunction · 0.85
newOp1Function · 0.85
newOp2Function · 0.85
assertMergeResultsFunction · 0.85
assertEqualRefsFunction · 0.85
assertNotEqualRefsFunction · 0.85
PushFunction · 0.70
FetchFunction · 0.70
MergeAllFunction · 0.70
ReadFunction · 0.70
AppendMethod · 0.65

Tested by

no test coverage detected