@@ -694,7 +694,6 @@ function getIndexesSuite() {
694
694
} ;
695
695
}
696
696
697
-
698
697
////////////////////////////////////////////////////////////////////////////////
699
698
/// @brief test suite: return value of getIndexes for an edge collection
700
699
////////////////////////////////////////////////////////////////////////////////
@@ -712,7 +711,7 @@ function getIndexesEdgesSuite() {
712
711
713
712
setUp : function ( ) {
714
713
internal . db . _drop ( cn ) ;
715
- collection = internal . db . _createEdgeCollection ( cn , { waitForSync : false } ) ;
714
+ collection = internal . db . _createEdgeCollection ( cn ) ;
716
715
} ,
717
716
718
717
////////////////////////////////////////////////////////////////////////////////
@@ -1049,6 +1048,73 @@ function getIndexesEdgesSuite() {
1049
1048
} ;
1050
1049
}
1051
1050
1051
+ ////////////////////////////////////////////////////////////////////////////////
1052
+ /// @brief test suite: test multi-index rollback
1053
+ ////////////////////////////////////////////////////////////////////////////////
1054
+
1055
+ function multiIndexRollbackSuite ( ) {
1056
+ 'use strict' ;
1057
+ var cn = "UnitTestsCollectionIdx" ;
1058
+ var collection = null ;
1059
+
1060
+ return {
1061
+
1062
+ ////////////////////////////////////////////////////////////////////////////////
1063
+ /// @brief set up
1064
+ ////////////////////////////////////////////////////////////////////////////////
1065
+
1066
+ setUp : function ( ) {
1067
+ internal . db . _drop ( cn ) ;
1068
+ collection = internal . db . _createEdgeCollection ( cn ) ;
1069
+ } ,
1070
+
1071
+ ////////////////////////////////////////////////////////////////////////////////
1072
+ /// @brief tear down
1073
+ ////////////////////////////////////////////////////////////////////////////////
1074
+
1075
+ tearDown : function ( ) {
1076
+ collection . drop ( ) ;
1077
+ collection = null ;
1078
+ } ,
1079
+
1080
+ ////////////////////////////////////////////////////////////////////////////////
1081
+ /// @brief test rollback on index insertion
1082
+ ////////////////////////////////////////////////////////////////////////////////
1083
+
1084
+ testIndexRollback : function ( ) {
1085
+ collection . ensureIndex ( { type : "hash" , fields : [ "_from" , "_to" , "link" ] , unique : true } ) ;
1086
+ collection . ensureIndex ( { type : "hash" , fields : [ "_to" , "ext" ] , unique : true , sparse : true } ) ;
1087
+
1088
+ var res = collection . getIndexes ( ) ;
1089
+
1090
+ assertEqual ( 4 , res . length ) ;
1091
+ assertEqual ( "primary" , res [ 0 ] . type ) ;
1092
+ assertEqual ( "edge" , res [ 1 ] . type ) ;
1093
+ assertEqual ( "hash" , res [ 2 ] . type ) ;
1094
+ assertEqual ( "hash" , res [ 3 ] . type ) ;
1095
+
1096
+ var docs = [
1097
+ { "_from" : "fromC/a" , "_to" : "toC/1" , "link" : "one" } ,
1098
+ { "_from" : "fromC/b" , "_to" : "toC/1" , "link" : "two" } ,
1099
+ { "_from" : "fromC/c" , "_to" : "toC/1" , "link" : "one" }
1100
+ ] ;
1101
+
1102
+ collection . insert ( docs ) ;
1103
+ assertEqual ( 3 , collection . count ( ) ) ;
1104
+
1105
+ try {
1106
+ internal . db . _query ( 'FOR doc IN [ {_from: "fromC/a", _to: "toC/1", link: "one", ext: 2337789}, {_from: "fromC/b", _to: "toC/1", link: "two", ext: 2337799}, {_from: "fromC/c", _to: "toC/1", link: "one", ext: 2337789} ] UPSERT {_from: doc._from, _to: doc._to, link: doc.link} INSERT { _from: doc._from, _to: doc._to, link: doc.link, ext: doc.ext} UPDATE {ext: doc.ext} IN ' + collection . name ( ) ) ;
1107
+ fail ( ) ;
1108
+ } catch ( err ) {
1109
+ assertEqual ( errors . ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED . code , err . errorNum ) ;
1110
+ }
1111
+
1112
+ res = internal . db . _query ( "FOR doc IN " + collection . name ( ) + " FILTER doc._to == 'toC/1' RETURN doc._from" ) . toArray ( ) ;
1113
+ assertEqual ( 3 , res . length ) ;
1114
+ }
1115
+
1116
+ } ;
1117
+ }
1052
1118
1053
1119
////////////////////////////////////////////////////////////////////////////////
1054
1120
/// @brief executes the test suites
@@ -1057,6 +1123,7 @@ function getIndexesEdgesSuite() {
1057
1123
jsunity . run ( indexSuite ) ;
1058
1124
jsunity . run ( getIndexesSuite ) ;
1059
1125
jsunity . run ( getIndexesEdgesSuite ) ;
1126
+ jsunity . run ( multiIndexRollbackSuite ) ;
1060
1127
1061
1128
return jsunity . done ( ) ;
1062
1129
0 commit comments