Skip to content

Commit

Permalink
Add failing test TestPruneRevsSingleTombstonedBranch()
Browse files Browse the repository at this point in the history
  • Loading branch information
Traun Leyden committed Jun 28, 2017
1 parent 468682d commit efd2f4c
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion db/revtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/couchbase/sync_gateway/base"
"github.com/couchbaselabs/go.assert"
"log"
)

// 1-one -- 2-two -- 3-three
Expand Down Expand Up @@ -336,6 +337,9 @@ func TestPruneRevisions(t *testing.T) {
}





func TestPruneRevsSingleBranch(t *testing.T) {

numRevs := 100
Expand Down Expand Up @@ -466,7 +470,7 @@ func TestGenerationShortestNonTombstonedBranch(t *testing.T) {

revTree := getMultiBranchTestRevtree1(3, 7, branchSpecs)

generationShortestNonTombstonedBranch := revTree.FindShortestNonTombstonedBranch()
generationShortestNonTombstonedBranch, _ := revTree.FindShortestNonTombstonedBranch()

// The "non-winning unresolved" branch has 7 revisions due to:
// 3 unconflictedBranchNumRevs
Expand Down Expand Up @@ -545,6 +549,33 @@ func TestPruneRevisionsPostIssue2651ThreeBranches(t *testing.T) {

}

func TestPruneRevsSingleTombstonedBranch(t *testing.T) {

numRevsTotal := 100
numRevsDeletedBranch := 99
branchSpecs := []BranchSpec{
{
NumRevs: numRevsDeletedBranch,
Digest: "single-tombstoned-branch",
LastRevisionIsTombstone: true,
},
}

revTree := getMultiBranchTestRevtree1(1, 0, branchSpecs)

maxDepth := uint32(20)
expectedNumPruned := numRevsTotal - int(maxDepth)

expectedNumPruned += 1 // To account for the tombstone revision in the branchspec, which is spearate from NumRevs

numPruned := revTree.pruneRevisions(maxDepth, "")

log.Printf("RevTreeAfter pruning: %v", revTree.RenderGraphvizDot())

assert.Equals(t, numPruned, expectedNumPruned)

}

func TestLongestBranch1(t *testing.T) {

branchSpecs := []BranchSpec{
Expand Down

0 comments on commit efd2f4c

Please sign in to comment.