mirror of https://gitee.com/bigwinds/arangodb
added test for issue #848
This commit is contained in:
parent
5d3d854495
commit
0218291d20
|
@ -1735,8 +1735,8 @@ function transactionGraphSuite () {
|
|||
db._drop(cn1);
|
||||
db._drop(cn2);
|
||||
|
||||
db._create(cn1);
|
||||
db._createEdgeCollection(cn2);
|
||||
c1 = db._create(cn1);
|
||||
c2 = db._createEdgeCollection(cn2);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1880,6 +1880,86 @@ function transactionGraphSuite () {
|
|||
assertEqual(result.oboyuhh._key, result.rldfnre._key);
|
||||
assertEqual("david smith", result.rldfnre.name);
|
||||
assertEqual(null, result.rldfnre.$label);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test: usage of read-copied documents inside write-transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testReadWriteDocumentsList : function () {
|
||||
c1.save({ _key: "bar" });
|
||||
c1.save({ _key: "baz" });
|
||||
c2.save(cn1 + "/bar", cn1 + "/baz", { type: "one" });
|
||||
c2.save(cn1 + "/baz", cn1 + "/bar", { type: "two" });
|
||||
|
||||
var obj = {
|
||||
collections: {
|
||||
write: [ cn2 ]
|
||||
},
|
||||
action : function () {
|
||||
var result = [ ];
|
||||
|
||||
result.push(c2.inEdges(cn1 + "/baz"));
|
||||
result.push(c2.inEdges(cn1 + "/bar"));
|
||||
|
||||
c2.save(cn1 + "/foo", cn1 + "/baz", { type: "three" });
|
||||
c2.save(cn1 + "/foo", cn1 + "/bar", { type: "four" });
|
||||
|
||||
result.push(c2.inEdges(cn1 + "/baz"));
|
||||
result.push(c2.inEdges(cn1 + "/bar"));
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
var sorter = function (l, r) {
|
||||
if (l.type !== r.type) {
|
||||
if (l.type < r.type) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
var result = TRANSACTION(obj);
|
||||
|
||||
assertEqual(4, result.length);
|
||||
var r = result[0];
|
||||
assertEqual(1, r.length);
|
||||
assertEqual(cn1 + "/bar", r[0]._from);
|
||||
assertEqual(cn1 + "/baz", r[0]._to);
|
||||
assertEqual("one", r[0].type);
|
||||
|
||||
r = result[1];
|
||||
assertEqual(1, r.length);
|
||||
assertEqual(cn1 + "/baz", r[0]._from);
|
||||
assertEqual(cn1 + "/bar", r[0]._to);
|
||||
assertEqual("two", r[0].type);
|
||||
|
||||
r = result[2];
|
||||
r.sort(sorter);
|
||||
|
||||
assertEqual(2, r.length);
|
||||
assertEqual(cn1 + "/bar", r[0]._from);
|
||||
assertEqual(cn1 + "/baz", r[0]._to);
|
||||
assertEqual("one", r[0].type);
|
||||
|
||||
assertEqual(cn1 + "/foo", r[1]._from);
|
||||
assertEqual(cn1 + "/baz", r[1]._to);
|
||||
assertEqual("three", r[1].type);
|
||||
|
||||
r = result[3];
|
||||
r.sort(sorter);
|
||||
|
||||
assertEqual(cn1 + "/foo", r[0]._from);
|
||||
assertEqual(cn1 + "/bar", r[0]._to);
|
||||
assertEqual("four", r[0].type);
|
||||
|
||||
assertEqual(2, r.length);
|
||||
assertEqual(cn1 + "/baz", r[1]._from);
|
||||
assertEqual(cn1 + "/bar", r[1]._to);
|
||||
assertEqual("two", r[1].type);
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue