Permalink
Browse files

(#635) - merge_rev_tree tests now support availability

That's quite to much said as they don't check if the availability
is merged correctly.
  • Loading branch information...
1 parent 8016337 commit 753a23d1087b4ab8e30ab14d2e1919430389e8a1 @neojski committed Apr 4, 2013
Showing with 65 additions and 65 deletions.
  1. +1 −1 tests/test.get.js
  2. +64 −64 tests/test.merge_rev_tree.js
View
@@ -232,7 +232,7 @@ adapters.map(function(adapter) {
var simpleTree = [
[
{_id: "foo", _rev: "1-a", value: "foo a"},
- {_id: "foo", _rev: "2-b", value: "foo d"},
+ {_id: "foo", _rev: "2-b", value: "foo b"},
{_id: "foo", _rev: "3-c", value: "foo c"}
],
[
@@ -16,29 +16,29 @@ if (typeof module !== undefined && module.exports) {
qunit('merge rev tree');
-var simple = {pos: 1, ids: ['1', {}, []]};
-var two0 = {pos: 1, ids: ['1', {}, [['2_0', {}, []]]]};
-var two1 = {pos: 1, ids: ['1', {}, [['2_1', {}, []]]]};
-var newleaf = {pos: 2, ids: ['2_0', {}, [['3', {}, []]]]};
-var withnewleaf = {pos: 1, ids: ['1', {}, [['2_0', {}, [['3', {}, []]]]]]};
-var newbranch = {pos: 1, ids: ['1', {}, [['2_0', {}, []], ['2_1', {}, []]]]};
-var newdeepbranch = {pos: 2, ids: ['2_0', {}, [['3_1', {}, []]]]};
-
-var stemmededit = {pos: 3, ids: ['3', {}, []]};
+var simple = {pos: 1, ids: ['1', {status: 'missing'}, []]};
+var two0 = {pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, []]]]};
+var two1 = {pos: 1, ids: ['1', {status: 'missing'}, [['2_1', {status: 'missing'}, []]]]};
+var newleaf = {pos: 2, ids: ['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []]]]};
+var withnewleaf = {pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []]]]]]};
+var newbranch = {pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, []], ['2_1', {status: 'missing'}, []]]]};
+var newdeepbranch = {pos: 2, ids: ['2_0', {status: 'missing'}, [['3_1', {status: 'missing'}, []]]]};
+
+var stemmededit = {pos: 3, ids: ['3', {status: 'missing'}, []]};
var stemmedconflicts = [simple, stemmededit];
-var newbranchleaf = {pos: 1, ids: ['1', {}, [['2_0', {}, [['3', {}, []]]], ['2_1', {}, []]]]};
-var newbranchleafbranch = {pos: 1, ids: ['1', {}, [['2_0', {}, [['3', {}, []], ['3_1', {}, []]]], ['2_1', {}, []]]]};
+var newbranchleaf = {pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []]]], ['2_1', {status: 'missing'}, []]]]};
+var newbranchleafbranch = {pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []], ['3_1', {status: 'missing'}, []]]], ['2_1', {status: 'missing'}, []]]]};
-var stemmed2 = [{pos: 1, ids: ['1', {}, [['2_1', {}, []]]]},
- {pos: 2, ids: ['2_0', {}, [['3', {}, []], ['3_1', {}, []]]]}];
+var stemmed2 = [{pos: 1, ids: ['1', {status: 'missing'}, [['2_1', {status: 'missing'}, []]]]},
+ {pos: 2, ids: ['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []], ['3_1', {status: 'missing'}, []]]]}];
-var stemmed3 = [{pos: 2, ids: ['2_1', {}, []]},
- {pos: 3, ids: ['3', {}, []]},
- {pos: 3, ids: ['3_1', {}, []]}];
-var partialrecover = [{pos: 1, ids: ['1', {}, [['2_0', {}, [['3', {}, []]]]]]},
- {pos: 2, ids: ['2_1', {}, []]},
- {pos: 3, ids: ['3_1', {}, []]}];
+var stemmed3 = [{pos: 2, ids: ['2_1', {status: 'missing'}, []]},
+ {pos: 3, ids: ['3', {status: 'missing'}, []]},
+ {pos: 3, ids: ['3_1', {status: 'missing'}, []]}];
+var partialrecover = [{pos: 1, ids: ['1', {status: 'missing'}, [['2_0', {status: 'missing'}, [['3', {status: 'missing'}, []]]]]]},
+ {pos: 2, ids: ['2_1', {status: 'missing'}, []]},
+ {pos: 3, ids: ['3_1', {status: 'missing'}, []]}];
test('Merging a path into an empty tree is the path', function() {
deepEqual(JSON.stringify(Pouch.merge([], simple, 10)), JSON.stringify({
@@ -148,10 +148,10 @@ test('Merging unstemmed recovers as much as possible without losing info', funct
test('winningRev returns the longest leaf', function() {
var tree = [
{"pos":1,"ids":[
- "bfe70372c90ded1087239e5191984f76", {}, [
- ["44d71a718b90e4696c06a90e08912c8f", {}, []],
- ["56e657612d55ab1a402dcb281c874f2a", {}, [
- ["93c3db16462f656f7172ccabd3cf6cd6", {}, []]
+ "bfe70372c90ded1087239e5191984f76", {status: 'missing'}, [
+ ["44d71a718b90e4696c06a90e08912c8f", {status: 'missing'}, []],
+ ["56e657612d55ab1a402dcb281c874f2a", {status: 'missing'}, [
+ ["93c3db16462f656f7172ccabd3cf6cd6", {status: 'missing'}, []]
]]
]]
}];
@@ -164,17 +164,17 @@ test('winningRev returns the longest leaf again', function() {
// this one is from issue #293
var tree = [
{"pos": 1,"ids": [
- "203db1a1810a838895d561f67b224b5d", {}, [
- ["bf5e08a4f9fa6d33a53f4a00ae3ea399", {}, [
- ["28cd77a3ca30f79e1cfffcd6a41ca308", {}, []]
+ "203db1a1810a838895d561f67b224b5d", {status: 'missing'}, [
+ ["bf5e08a4f9fa6d33a53f4a00ae3ea399", {status: 'missing'}, [
+ ["28cd77a3ca30f79e1cfffcd6a41ca308", {status: 'missing'}, []]
]]
]
]},
{"pos": 1,"ids": [
- "c6d5cce35bcfbef90b20f140d723cbdb", {}, [
- ["1b8dfbb1267e213328920bae43f2f597", {}, []],
- ["59ed830b84b276ab776c3c51aaf93a16", {}, [
- ["64a9842c6aea50bf24660378e496e853", {}, []]
+ "c6d5cce35bcfbef90b20f140d723cbdb", {status: 'missing'}, [
+ ["1b8dfbb1267e213328920bae43f2f597", {status: 'missing'}, []],
+ ["59ed830b84b276ab776c3c51aaf93a16", {status: 'missing'}, [
+ ["64a9842c6aea50bf24660378e496e853", {status: 'missing'}, []]
]]
]]
}
@@ -186,7 +186,7 @@ test('winningRev returns the longest leaf again', function() {
///// These are tests from CouchDB's kt-merging.erl test suite
-var one = {pos: 1, ids: ['1', {}, []]};
+var one = {pos: 1, ids: ['1', {status: 'missing'}, []]};
test('The empty tree is the identity for merge.', function() {
deepEqual(Pouch.merge([], one, 10), {
tree: [one],
@@ -201,7 +201,7 @@ test('Merging is reflexive', function() {
});
});
-var two = {pos: 1, ids: ['2', {}, []]};
+var two = {pos: 1, ids: ['2', {status: 'missing'}, []]};
var twoSibs = [one, two];
test('Merging a prefix of a tree with the tree yields the tree.', function() {
deepEqual(Pouch.merge(twoSibs, one, 10), {
@@ -210,7 +210,7 @@ test('Merging a prefix of a tree with the tree yields the tree.', function() {
});
});
-var three = {pos: 1, ids: ['3', {}, []]};
+var three = {pos: 1, ids: ['3', {status: 'missing'}, []]};
var threeSibs = [one, two, three];
test('Merging a third unrelated branch leads to a conflict.', function() {
deepEqual(Pouch.merge(twoSibs, three, 10), {
@@ -219,9 +219,9 @@ test('Merging a third unrelated branch leads to a conflict.', function() {
});
});
-var twoChild = {pos: 1, ids: ['1', {}, [
- ['1a', {}, [
- ['1aa', {}, []]
+var twoChild = {pos: 1, ids: ['1', {status: 'missing'}, [
+ ['1a', {status: 'missing'}, [
+ ['1aa', {status: 'missing'}, []]
]]
]]};
test('Merging two children is still reflexive.', function() {
@@ -231,9 +231,9 @@ test('Merging two children is still reflexive.', function() {
});
});
-var twoChildSibs = {pos: 1, ids: ['1', {}, [
- ['1a', {}, []],
- ['1b', {}, []]
+var twoChildSibs = {pos: 1, ids: ['1', {status: 'missing'}, [
+ ['1a', {status: 'missing'}, []],
+ ['1b', {status: 'missing'}, []]
]]};
test('Merging a tree to itself is itself.', function() {
deepEqual(Pouch.merge([twoChildSibs], twoChildSibs, 10), {
@@ -242,11 +242,11 @@ test('Merging a tree to itself is itself.', function() {
});
});
-var twoChildPlusSibs = {pos: 1, ids: ['1', {}, [
- ['1a', {}, [
- ['1aa', {}, []]
+var twoChildPlusSibs = {pos: 1, ids: ['1', {status: 'missing'}, [
+ ['1a', {status: 'missing'}, [
+ ['1aa', {status: 'missing'}, []]
]],
- ['1b', {}, []]
+ ['1b', {status: 'missing'}, []]
]]};
test('Merging tree of uneven length at node 2.', function() {
deepEqual(Pouch.merge([twoChild], twoChildSibs, 10), {
@@ -255,21 +255,21 @@ test('Merging tree of uneven length at node 2.', function() {
});
});
-var stemmed1b = {pos: 2, ids: ['1a', {}, []]};
+var stemmed1b = {pos: 2, ids: ['1a', {status: 'missing'}, []]};
test('Merging a tree with a stem.', function() {
deepEqual(Pouch.merge([twoChildSibs], stemmed1b, 10), {
tree: [twoChildSibs],
conflicts: 'internal_node'
});
});
-var twoChildPlusSibs2 = {pos: 1, ids: ['1', {}, [
- ['1a', {}, []],
- ['1b', {}, [
- ['1bb', {}, []]
+var twoChildPlusSibs2 = {pos: 1, ids: ['1', {status: 'missing'}, [
+ ['1a', {status: 'missing'}, []],
+ ['1b', {status: 'missing'}, [
+ ['1bb', {status: 'missing'}, []]
]]
]]};
-var stemmed1bb = {pos:3, ids: ['1bb', {}, []]};
+var stemmed1bb = {pos:3, ids: ['1bb', {status: 'missing'}, []]};
test('Merging a stem at a deeper level.', function() {
deepEqual(Pouch.merge([twoChildPlusSibs2], stemmed1bb, 10), {
tree: [twoChildPlusSibs2],
@@ -278,8 +278,8 @@ test('Merging a stem at a deeper level.', function() {
});
var stemmedTwoChildSibs2 = [
- {pos: 2, ids: ['1a', {}, []]},
- {pos: 2, ids: ['1b', {}, [['1bb', {}, []]]]}
+ {pos: 2, ids: ['1a', {status: 'missing'}, []]},
+ {pos: 2, ids: ['1b', {status: 'missing'}, [['1bb', {status: 'missing'}, []]]]}
];
test('Merging a stem at a deeper level against paths at deeper levels.', function() {
deepEqual(Pouch.merge(stemmedTwoChildSibs2, stemmed1bb, 10), {
@@ -288,15 +288,15 @@ test('Merging a stem at a deeper level against paths at deeper levels.', functio
});
});
-var stemmed1aa = {pos: 3, ids: ['1aa', {}, []]};
+var stemmed1aa = {pos: 3, ids: ['1aa', {status: 'missing'}, []]};
test("Merging a single tree with a deeper stem.", function() {
deepEqual(Pouch.merge([twoChild], stemmed1aa, 10), {
tree: [twoChild],
conflicts: 'internal_node'
});
});
-var stemmed1a = {pos: 2, ids: ['1a', {}, [['1aa', {}, []]]]};
+var stemmed1a = {pos: 2, ids: ['1a', {status: 'missing'}, [['1aa', {status: 'missing'}, []]]]};
test('Merging a larger stem.', function() {
deepEqual(Pouch.merge([twoChild], stemmed1a, 10), {
tree: [twoChild],
@@ -311,7 +311,7 @@ test('More merging.', function() {
});
});
-var oneChild = {pos: 1, ids: ['1', {}, [['1a', {}, []]]]};
+var oneChild = {pos: 1, ids: ['1', {status: 'missing'}, [['1a', {status: 'missing'}, []]]]};
test('Merging should create conflicts.', function() {
deepEqual(Pouch.merge([oneChild], stemmed1aa, 10), {
tree: [oneChild, stemmed1aa],
@@ -326,19 +326,19 @@ test('Merging should have no conflicts.', function() {
});
});
-var foo = {pos: 1, ids: ['foo', {}, [
- ['foo2', {}, []],
- ['foo3', {}, []]
+var foo = {pos: 1, ids: ['foo', {status: 'missing'}, [
+ ['foo2', {status: 'missing'}, []],
+ ['foo3', {status: 'missing'}, []]
]]};
-var bar = {pos: 1, ids: ['foo', {}, [
- ['foo3', {}, [
- ['foo4', {}, []]
+var bar = {pos: 1, ids: ['foo', {status: 'missing'}, [
+ ['foo3', {status: 'missing'}, [
+ ['foo4', {status: 'missing'}, []]
]]
]]};
-var fooBar = {pos: 1, ids: ['foo', {}, [
- ['foo2', {}, []],
- ['foo3', {}, [
- ['foo4', {}, []]
+var fooBar = {pos: 1, ids: ['foo', {status: 'missing'}, [
+ ['foo2', {status: 'missing'}, []],
+ ['foo3', {status: 'missing'}, [
+ ['foo4', {status: 'missing'}, []]
]]
]]};
test('Merging trees with conflicts ought to behave.', function() {

0 comments on commit 753a23d

Please sign in to comment.