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

Function TestTreeDiff

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

Source from the content-addressed store, hash-verified

149}
150
151func TestTreeDiff(t *testing.T) {
152 Convey("Test Tree Diffs", t, func() {
153
154 var left, right *memory.MemDB
155 Convey("Test empty source and target", func() {
156 left = memory.NewMemDB()
157 right = memory.NewMemDB()
158 t1, _ := TreeNodeFromSource(testCtx, left, "/", []glob.Glob{}, []glob.Glob{})
159 // Trigger printout for test coverage
160 t.Log(t1.PrintTree())
161 diff := newTreeDiff(left, right)
162 e := diff.Compute(testCtx, "/", nil, nil)
163 So(e, ShouldBeNil)
164 So(diff.missingLeft, ShouldHaveLength, 0)
165 So(diff.missingRight, ShouldHaveLength, 0)
166
167 })
168
169 Convey("Test file in left", func() {
170 left = memory.NewMemDB()
171 right = memory.NewMemDB()
172 left.CreateNode(testCtx, &tree.Node{
173 Path: "/aaa",
174 Type: tree.NodeType_LEAF,
175 Etag: "hash",
176 }, true)
177 diff := newTreeDiff(left, right)
178 e := diff.Compute(testCtx, "/", nil, nil)
179 So(e, ShouldBeNil)
180 So(diff.missingLeft, ShouldHaveLength, 0)
181 So(diff.missingRight, ShouldHaveLength, 1)
182 })
183
184 Convey("Test file in right", func() {
185 left = memory.NewMemDB()
186 right = memory.NewMemDB()
187 right.CreateNode(testCtx, &tree.Node{
188 Path: "/aaa",
189 Type: tree.NodeType_LEAF,
190 Etag: "hash",
191 }, true)
192 diff := newTreeDiff(left, right)
193 e := diff.Compute(testCtx, "/", nil, nil)
194 So(e, ShouldBeNil)
195 So(diff.missingLeft, ShouldHaveLength, 1)
196 So(diff.missingRight, ShouldHaveLength, 0)
197 })
198
199 Convey("Test files in both", func() {
200 left = memory.NewMemDB()
201 right = memory.NewMemDB()
202 right.CreateNode(testCtx, &tree.Node{
203 Path: "/aaa",
204 Type: tree.NodeType_LEAF,
205 Etag: "hash",
206 }, true)
207 left.CreateNode(testCtx, &tree.Node{
208 Path: "/aaa",

Callers

nothing calls this directly

Calls 13

CreateNodeMethod · 0.95
NewMemDBFunction · 0.92
TreeNodeFromSourceFunction · 0.85
newTreeDiffFunction · 0.85
newTreePatchFunction · 0.85
makeFunction · 0.85
LogMethod · 0.80
PrintTreeMethod · 0.80
ComputeMethod · 0.65
GetHashMethod · 0.65
ToUnidirectionalPatchMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…