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

Function TestTreeNodeFromSourceWithMeta

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

Source from the content-addressed store, hash-verified

723}
724
725func TestTreeNodeFromSourceWithMeta(t *testing.T) {
726
727 Convey("Test Loading Meta", t, func() {
728
729 left := memory.NewMemDB()
730 left.CreateNode(testCtx, &tree.Node{Path: "/aaa", Type: tree.NodeType_COLLECTION, Etag: "-1", MetaStore: map[string]string{
731 "pydio:special-meta-1": "value1",
732 }}, true)
733 left.CreateNode(testCtx, &tree.Node{Path: "/aaa/a", Type: tree.NodeType_LEAF, Etag: "hasha", MetaStore: map[string]string{
734 "pydio:special-meta-1": "value1",
735 "pydio:special-meta-2": "value2",
736 }}, true)
737 left.CreateNode(testCtx, &tree.Node{Path: "/aaa/b", Type: tree.NodeType_LEAF, Etag: "hashme", MetaStore: map[string]string{
738 "other-meta": "other-value",
739 }}, true)
740
741 metaGlobs := []glob.Glob{
742 glob.MustCompile("pydio:special-meta-*"),
743 }
744 _, e := TreeNodeFromSource(testCtx, left, "/", nil, metaGlobs)
745 So(e, ShouldBeNil)
746
747 })
748
749 Convey("Test Diffing Metas", t, func() {
750
751 left := memory.NewMemDB()
752 left.CreateNode(testCtx, &tree.Node{Path: "aaa", Type: tree.NodeType_COLLECTION, Uuid: "node-1", Etag: "-1", MetaStore: map[string]string{
753 "pydio:special-meta-1": "value1",
754 }}, true)
755 left.CreateNode(testCtx, &tree.Node{Path: "aaa/a", Type: tree.NodeType_LEAF, Uuid: "node-2", Etag: "hasha", MetaStore: map[string]string{
756 "pydio:special-meta-1": "value-similar",
757 "pydio:special-meta-deleted": "value2",
758 }}, true)
759
760 right := memory.NewMemDB()
761 right.CreateNode(testCtx, &tree.Node{Path: "aaa", Type: tree.NodeType_COLLECTION, Uuid: "node-1", Etag: "-1", MetaStore: map[string]string{
762 "pydio:special-meta-1": "value-changed",
763 }}, true)
764 right.CreateNode(testCtx, &tree.Node{Path: "aaa/a", Type: tree.NodeType_LEAF, Uuid: "node-2", Etag: "hasha", MetaStore: map[string]string{
765 "pydio:special-meta-1": "value-similar",
766 "pydio:special-meta-created": "new-value",
767 }}, true)
768
769 metaGlobs := []glob.Glob{
770 glob.MustCompile("pydio:special-meta-*"),
771 }
772
773 diff := NewTreeDiff(left, right)
774 diff.includeMetas = metaGlobs
775 e := diff.Compute(testCtx, "", nil, nil)
776 So(e, ShouldBeNil)
777 t.Log(diff.String())
778
779 p := newTreePatch(left, right, PatchOptions{})
780 err := diff.ToUnidirectionalPatch(testCtx, model.DirectionRight, p)
781 So(err, ShouldBeNil)
782 t.Log(p)

Callers

nothing calls this directly

Calls 11

CreateNodeMethod · 0.95
ComputeMethod · 0.95
StringMethod · 0.95
ToUnidirectionalPatchMethod · 0.95
NewMemDBFunction · 0.92
TreeNodeFromSourceFunction · 0.85
NewTreeDiffFunction · 0.85
newTreePatchFunction · 0.85
LogMethod · 0.80
WalkOperationsMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…