MCPcopy Create free account
hub / github.com/pydio/cells / TestComputeSourcesDiff

Function TestComputeSourcesDiff

common/sync/merger/tree-diff_test.go:41–149  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39)
40
41func TestComputeSourcesDiff(t *testing.T) {
42 Convey("Test various Diffs", t, func() {
43
44 var left, right *memory.MemDB
45 var diff *TreeDiff
46
47 Convey("Test empty source and target", func() {
48 left = memory.NewMemDB()
49 right = memory.NewMemDB()
50 diff = newTreeDiff(left, right)
51 e := diff.Compute(testCtx, "/", nil, nil)
52 So(e, ShouldBeNil)
53 So(diff, ShouldNotBeNil)
54 So(diff.missingLeft, ShouldHaveLength, 0)
55 So(diff.missingRight, ShouldHaveLength, 0)
56 })
57
58 Convey("Test file in left", func() {
59 left = memory.NewMemDB()
60 right = memory.NewMemDB()
61 left.CreateNode(testCtx, &tree.Node{
62 Path: "/aaa",
63 Type: tree.NodeType_LEAF,
64 Etag: "hash",
65 }, true)
66 diff = newTreeDiff(left, right)
67 e := diff.Compute(testCtx, "/", nil, nil)
68 So(e, ShouldBeNil)
69 So(diff.missingLeft, ShouldHaveLength, 0)
70 So(diff.missingRight, ShouldHaveLength, 1)
71 })
72
73 Convey("Test file in right", func() {
74 left = memory.NewMemDB()
75 right = memory.NewMemDB()
76 right.CreateNode(testCtx, &tree.Node{
77 Path: "/aaa",
78 Type: tree.NodeType_LEAF,
79 Etag: "hash",
80 }, true)
81 diff = newTreeDiff(left, right)
82 e := diff.Compute(testCtx, "/", nil, nil)
83 So(e, ShouldBeNil)
84 So(diff.missingLeft, ShouldHaveLength, 1)
85 So(diff.missingRight, ShouldHaveLength, 0)
86 })
87
88 Convey("Test files in both", func() {
89 left = memory.NewMemDB()
90 right = memory.NewMemDB()
91 right.CreateNode(testCtx, &tree.Node{
92 Path: "/aaa",
93 Type: tree.NodeType_LEAF,
94 Etag: "hash",
95 }, true)
96 left.CreateNode(testCtx, &tree.Node{
97 Path: "/aaa",
98 Type: tree.NodeType_LEAF,

Callers

nothing calls this directly

Calls 4

ComputeMethod · 0.95
CreateNodeMethod · 0.95
NewMemDBFunction · 0.92
newTreeDiffFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…