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 ;
@@ -1224,4 +1225,43 @@ describe('Examples', function() {
1224
1225
} ) ;
1225
1226
}
1226
1227
} ) ;
1228
+
1229
+ /**
1230
+ * @ignore
1231
+ */
1232
+ it ( 'CausalConsistency' , {
1233
+ metadata : { requires : { topology : [ 'single' ] , mongodb : '>=3.6.0' } } ,
1234
+
1235
+ test : function ( done ) {
1236
+ const configuration = this . configuration ;
1237
+ const client = configuration . newClient ( configuration . writeConcernMax ( ) , { poolSize : 1 } ) ;
1238
+
1239
+ client . connect ( function ( err , client ) {
1240
+ const cleanup = e => {
1241
+ client . close ( ) ;
1242
+ done ( e ) ;
1243
+ } ;
1244
+
1245
+ if ( err ) return cleanup ( err ) ;
1246
+
1247
+ const db = client . db ( configuration . db ) ;
1248
+ const collection = db . collection ( 'causalConsistencyExample' ) ;
1249
+ const session = client . startSession ( { causalConsistency : true } ) ;
1250
+
1251
+ collection . insertOne ( { darmok : 'jalad' } , { session } ) ;
1252
+ collection . updateOne ( { darmok : 'jalad' } , { $set : { darmok : 'tanagra' } } , { session } ) ;
1253
+
1254
+ collection . find ( { } , { session } ) . toArray ( function ( err , data ) {
1255
+ try {
1256
+ expect ( err ) . to . equal ( null ) ;
1257
+ expect ( data ) . to . exist ;
1258
+ } catch ( e ) {
1259
+ return cleanup ( e ) ;
1260
+ }
1261
+
1262
+ cleanup ( ) ;
1263
+ } ) ;
1264
+ } ) ;
1265
+ }
1266
+ } ) ;
1227
1267
} ) ;
You can’t perform that action at this time.
0 commit comments