From 4eb495cd1ef96155b8f50f04305fdb7e39f0173e Mon Sep 17 00:00:00 2001 From: MoonGyu1 Date: Thu, 10 Aug 2023 15:09:31 +0900 Subject: [PATCH] Rename TreePos to TreeNodeID --- pkg/document/crdt/tree_test.go | 20 ++++++++++---------- test/helper/helper.go | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/document/crdt/tree_test.go b/pkg/document/crdt/tree_test.go index 7f9565cf5..236ad39e2 100644 --- a/pkg/document/crdt/tree_test.go +++ b/pkg/document/crdt/tree_test.go @@ -28,8 +28,8 @@ import ( func TestTreeNode(t *testing.T) { t.Run("text node test", func(t *testing.T) { - node := crdt.NewTreeNode(crdt.DummyTreePos, "text", nil, "hello") - assert.Equal(t, crdt.DummyTreePos, node.Pos) + node := crdt.NewTreeNode(crdt.DummyTreeNodeId, "text", nil, "hello") + assert.Equal(t, crdt.DummyTreeNodeId, node.Pos) assert.Equal(t, "text", node.Type()) assert.Equal(t, "hello", node.Value) assert.Equal(t, 5, node.Len()) @@ -38,8 +38,8 @@ func TestTreeNode(t *testing.T) { }) t.Run("element node test", func(t *testing.T) { - para := crdt.NewTreeNode(crdt.DummyTreePos, "p", nil) - err := para.Append(crdt.NewTreeNode(crdt.DummyTreePos, "text", nil, "helloyorkie")) + para := crdt.NewTreeNode(crdt.DummyTreeNodeId, "p", nil) + err := para.Append(crdt.NewTreeNode(crdt.DummyTreeNodeId, "text", nil, "helloyorkie")) assert.NoError(t, err) assert.Equal(t, "

helloyorkie

", crdt.ToXML(para)) assert.Equal(t, 11, para.Len()) @@ -54,15 +54,15 @@ func TestTreeNode(t *testing.T) { assert.Equal(t, "hello", left.Value) assert.Equal(t, "yorkie", right.Value) - assert.Equal(t, &crdt.TreePos{CreatedAt: time.InitialTicket, Offset: 0}, left.Pos) - assert.Equal(t, &crdt.TreePos{CreatedAt: time.InitialTicket, Offset: 5}, right.Pos) + assert.Equal(t, &crdt.TreeNodeID{CreatedAt: time.InitialTicket, Offset: 0}, left.Pos) + assert.Equal(t, &crdt.TreeNodeID{CreatedAt: time.InitialTicket, Offset: 5}, right.Pos) }) t.Run("element node with attributes test", func(t *testing.T) { attrs := crdt.NewRHT() attrs.Set("font-weight", "bold", time.InitialTicket) - node := crdt.NewTreeNode(crdt.DummyTreePos, "span", attrs) - err := node.Append(crdt.NewTreeNode(crdt.DummyTreePos, "text", nil, "helloyorkie")) + node := crdt.NewTreeNode(crdt.DummyTreeNodeId, "span", attrs) + err := node.Append(crdt.NewTreeNode(crdt.DummyTreeNodeId, "text", nil, "helloyorkie")) assert.NoError(t, err) assert.Equal(t, `helloyorkie`, crdt.ToXML(node)) }) @@ -79,8 +79,8 @@ func TestTreeNode(t *testing.T) { {12, "🌷🎁💩😜👍🏳"}, } for _, test := range tests { - para := crdt.NewTreeNode(crdt.DummyTreePos, "p", nil) - err := para.Append(crdt.NewTreeNode(crdt.DummyTreePos, "text", nil, test.value)) + para := crdt.NewTreeNode(crdt.DummyTreeNodeId, "p", nil) + err := para.Append(crdt.NewTreeNode(crdt.DummyTreeNodeId, "text", nil, test.value)) assert.NoError(t, err) left, err := para.Child(0) assert.NoError(t, err) diff --git a/test/helper/helper.go b/test/helper/helper.go index 424e9f432..4b5d73fda 100644 --- a/test/helper/helper.go +++ b/test/helper/helper.go @@ -113,9 +113,9 @@ func TextChangeContext(root *crdt.Root) *change.Context { ) } -// IssuePos is a helper function that issues a new CRDTTreePos. -func IssuePos(change *change.Context, offset ...int) *crdt.TreePos { - pos := &crdt.TreePos{ +// IssuePos is a helper function that issues a new CRDTTreeNodeID. +func IssuePos(change *change.Context, offset ...int) *crdt.TreeNodeID { + pos := &crdt.TreeNodeID{ CreatedAt: change.IssueTimeTicket(), Offset: 0, }