Skip to content

Commit

Permalink
Erase duplicate test
Browse files Browse the repository at this point in the history
  • Loading branch information
raararaara committed Nov 19, 2024
1 parent 3cf29bf commit c7770f2
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions test/integration/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,78 +295,6 @@ func TestGarbageCollection(t *testing.T) {
assert.Equal(t, 0, doc.GarbageLen())
})

t.Run("garbage collection for tree type test", func(t *testing.T) {
doc := document.New(helper.TestDocKey(t))

err := doc.Update(func(root *json.Object, p *presence.Presence) error {
root.SetNewTree("t", &json.TreeNode{
Type: "doc",
Children: []json.TreeNode{{
Type: "p", Children: []json.TreeNode{{
Type: "tn", Children: []json.TreeNode{{
Type: "text", Value: "a",
}, {
Type: "text", Value: "b",
}},
}, {
Type: "tn", Children: []json.TreeNode{{
Type: "text", Value: "cd",
}},
}},
}},
})
assert.Equal(t, `<doc><p><tn>ab</tn><tn>cd</tn></p></doc>`, root.GetTree("t").ToXML())

return nil
})
assert.Equal(t, true, checkVV(doc.VersionVector(), versionOf(doc.ActorID(), 1)))
assert.NoError(t, err)

err = doc.Update(func(root *json.Object, p *presence.Presence) error {
root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "gh"}, 0)
assert.Equal(t, `<doc><p><tn>gh</tn><tn>cd</tn></p></doc>`, root.GetTree("t").ToXML())
return nil
})

// [text(a), text(b)]
assert.Equal(t, true, checkVV(doc.VersionVector(), versionOf(doc.ActorID(), 2)))
assert.NoError(t, err)
assert.Equal(t, doc.GarbageLen(), 2)
assert.Equal(t, doc.GarbageCollect(helper.MaxVersionVector(doc.ActorID())), 2)
assert.Equal(t, doc.GarbageLen(), 0)

err = doc.Update(func(root *json.Object, p *presence.Presence) error {
root.GetTree("t").EditByPath([]int{0, 0, 0}, []int{0, 0, 2}, &json.TreeNode{Type: "text", Value: "cv"}, 0)
assert.Equal(t, `<doc><p><tn>cv</tn><tn>cd</tn></p></doc>`, root.GetTree("t").ToXML())
return nil
})

// [text(gh)]
assert.Equal(t, true, checkVV(doc.VersionVector(), versionOf(doc.ActorID(), 3)))
assert.NoError(t, err)
assert.Equal(t, doc.GarbageLen(), 1)
assert.Equal(t, doc.GarbageCollect(helper.MaxVersionVector(doc.ActorID())), 1)
assert.Equal(t, doc.GarbageLen(), 0)

err = doc.Update(func(root *json.Object, p *presence.Presence) error {
root.GetTree("t").EditByPath([]int{0}, []int{1}, &json.TreeNode{
Type: "p", Children: []json.TreeNode{{
Type: "tn", Children: []json.TreeNode{{
Type: "text", Value: "ab",
}},
}}}, 0)
assert.Equal(t, `<doc><p><tn>ab</tn></p></doc>`, root.GetTree("t").ToXML())
return nil
})

// [p, tn, tn, text(cv), text(cd)]
assert.Equal(t, true, checkVV(doc.VersionVector(), versionOf(doc.ActorID(), 4)))
assert.NoError(t, err)
assert.Equal(t, doc.GarbageLen(), 5)
assert.Equal(t, doc.GarbageCollect(helper.MaxVersionVector(doc.ActorID())), 5)
assert.Equal(t, doc.GarbageLen(), 0)
})

t.Run("garbage collection for tree type test (multi clients)", func(t *testing.T) {
ctx := context.Background()
d1 := document.New(helper.TestDocKey(t))
Expand Down

0 comments on commit c7770f2

Please sign in to comment.