File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
var assert = require ( 'assert' ) ;
4
+ const expect = require ( 'chai' ) . expect ;
4
5
var co = require ( 'co' ) ;
5
6
var test = require ( './shared' ) . assert ;
6
7
var setupDatabase = require ( './shared' ) . setupDatabase ;
@@ -1192,4 +1193,43 @@ describe('Examples', function() {
1192
1193
} ) ;
1193
1194
}
1194
1195
} ) ;
1196
+
1197
+ /**
1198
+ * @ignore
1199
+ */
1200
+ it ( 'CausalConsistency' , {
1201
+ metadata : { requires : { topology : [ 'single' ] , mongodb : '>=3.6.0' } } ,
1202
+
1203
+ test : function ( done ) {
1204
+ const configuration = this . configuration ;
1205
+ const client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
1206
+
1207
+ client . connect ( function ( err , client ) {
1208
+ const cleanup = e => {
1209
+ client . close ( ) ;
1210
+ done ( e ) ;
1211
+ } ;
1212
+
1213
+ if ( err ) return cleanup ( err ) ;
1214
+
1215
+ const db = client . db ( configuration . db ) ;
1216
+ const collection = db . collection ( 'causalConsistencyExample' ) ;
1217
+ const session = client . startSession ( { causalConsistency : true } ) ;
1218
+
1219
+ collection . insertOne ( { darmok : 'jalad' } , { session } ) ;
1220
+ collection . updateOne ( { darmok : 'jalad' } , { $set : { darmok : 'tanagra' } } , { session } ) ;
1221
+
1222
+ collection . find ( { } , { session } ) . toArray ( function ( err , data ) {
1223
+ try {
1224
+ expect ( err ) . to . equal ( null ) ;
1225
+ expect ( data ) . to . exist ;
1226
+ } catch ( e ) {
1227
+ return cleanup ( e ) ;
1228
+ }
1229
+
1230
+ cleanup ( ) ;
1231
+ } ) ;
1232
+ } ) ;
1233
+ }
1234
+ } ) ;
1195
1235
} ) ;
You can’t perform that action at this time.
0 commit comments