@@ -14,7 +14,7 @@ exports['should correctly execute find method using crud api'] = {
14
14
// Add a tag that our runner can trigger on
15
15
// in this case we are setting that node needs to be higher than 0.10.X to run
16
16
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
17
-
17
+
18
18
// The actual test we wish to run
19
19
test : function ( configuration , test ) {
20
20
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -40,7 +40,7 @@ exports['should correctly execute find method using crud api'] = {
40
40
. skip ( 0 )
41
41
. sort ( { a :1 } ) ;
42
42
43
- //
43
+ //
44
44
// Exercise count method
45
45
// -------------------------------------------------
46
46
var countMethod = function ( ) {
@@ -52,12 +52,12 @@ exports['should correctly execute find method using crud api'] = {
52
52
} ) ;
53
53
}
54
54
55
- //
55
+ //
56
56
// Exercise legacy method each
57
57
// -------------------------------------------------
58
58
var eachMethod = function ( ) {
59
59
var count = 0 ;
60
-
60
+
61
61
cursor . each ( function ( err , doc ) {
62
62
test . equal ( null , err ) ;
63
63
if ( doc ) count = count + 1 ;
@@ -98,7 +98,7 @@ exports['should correctly execute find method using crud api'] = {
98
98
nextObjectMethod ( ) ;
99
99
} ) ;
100
100
} ) ;
101
- } ) ;
101
+ } ) ;
102
102
}
103
103
104
104
//
@@ -120,7 +120,7 @@ exports['should correctly execute find method using crud api'] = {
120
120
streamMethod ( ) ;
121
121
} ) ;
122
122
} ) ;
123
- } ) ;
123
+ } ) ;
124
124
}
125
125
126
126
//
@@ -134,7 +134,7 @@ exports['should correctly execute find method using crud api'] = {
134
134
} ) ;
135
135
136
136
clonedCursor . once ( 'end' , function ( ) {
137
- test . equal ( 2 , count ) ;
137
+ test . equal ( 2 , count ) ;
138
138
explainMethod ( ) ;
139
139
} ) ;
140
140
}
@@ -149,7 +149,7 @@ exports['should correctly execute find method using crud api'] = {
149
149
test . ok ( result != null ) ;
150
150
151
151
db . close ( ) ;
152
- test . done ( ) ;
152
+ test . done ( ) ;
153
153
} ) ;
154
154
}
155
155
@@ -167,7 +167,7 @@ exports['should correctly execute aggregation method using crud api'] = {
167
167
// Add a tag that our runner can trigger on
168
168
// in this case we are setting that node needs to be higher than 0.10.X to run
169
169
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
170
-
170
+
171
171
// The actual test we wish to run
172
172
test : function ( configuration , test ) {
173
173
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -218,7 +218,7 @@ exports['should correctly execute aggregation method using crud api'] = {
218
218
test . equal ( null , err ) ;
219
219
test . equal ( 3 , docs . length ) ;
220
220
testNext ( ) ;
221
- } ) ;
221
+ } ) ;
222
222
}
223
223
224
224
//
@@ -247,7 +247,7 @@ exports['should correctly execute aggregation method using crud api'] = {
247
247
test . equal ( 3 , count ) ;
248
248
testStream ( ) ;
249
249
}
250
- } ) ;
250
+ } ) ;
251
251
}
252
252
253
253
//
@@ -262,9 +262,9 @@ exports['should correctly execute aggregation method using crud api'] = {
262
262
} ) ;
263
263
264
264
cursor . once ( 'end' , function ( ) {
265
- test . equal ( 3 , count ) ;
265
+ test . equal ( 3 , count ) ;
266
266
testExplain ( ) ;
267
- } ) ;
267
+ } ) ;
268
268
}
269
269
270
270
//
@@ -278,7 +278,7 @@ exports['should correctly execute aggregation method using crud api'] = {
278
278
279
279
db . close ( ) ;
280
280
test . done ( ) ;
281
- } ) ;
281
+ } ) ;
282
282
}
283
283
284
284
testAllMethods ( ) ;
@@ -291,7 +291,7 @@ exports['should correctly execute insert methods using crud api'] = {
291
291
// Add a tag that our runner can trigger on
292
292
// in this case we are setting that node needs to be higher than 0.10.X to run
293
293
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
294
-
294
+
295
295
// The actual test we wish to run
296
296
test : function ( configuration , test ) {
297
297
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -316,7 +316,7 @@ exports['should correctly execute insert methods using crud api'] = {
316
316
var bulkAPIInsert = function ( ) {
317
317
var bulk = db . collection ( 't2_2' ) . initializeOrderedBulkOp ( ) ;
318
318
bulk . insert ( { a :1 } ) ;
319
- bulk . insert ( { a :1 } ) ;
319
+ bulk . insert ( { a :1 } ) ;
320
320
bulk . execute ( function ( err , r ) {
321
321
test . equal ( null , err ) ;
322
322
@@ -333,7 +333,7 @@ exports['should correctly execute insert methods using crud api'] = {
333
333
test . equal ( 1 , r . result . n ) ;
334
334
test . equal ( 1 , r . insertedCount ) ;
335
335
test . ok ( r . insertedId != null ) ;
336
-
336
+
337
337
insertMany ( ) ;
338
338
} ) ;
339
339
}
@@ -348,7 +348,7 @@ exports['should correctly execute insert methods using crud api'] = {
348
348
test . equal ( 2 , r . result . n ) ;
349
349
test . equal ( 2 , r . insertedCount ) ;
350
350
test . equal ( 2 , r . insertedIds . length ) ;
351
-
351
+
352
352
// Ordered bulk unordered
353
353
bulkWriteUnOrdered ( ) ;
354
354
} ) ;
@@ -361,7 +361,7 @@ exports['should correctly execute insert methods using crud api'] = {
361
361
db . collection ( 't2_5' ) . insertMany ( [ { c :1 } ] , { w :1 } , function ( err , r ) {
362
362
test . equal ( null , err ) ;
363
363
test . equal ( 1 , r . result . n ) ;
364
-
364
+
365
365
db . collection ( 't2_5' ) . bulkWrite ( [
366
366
{ insertOne : { a : 1 } }
367
367
, { insertMany : [ { g : 1 } , { g : 2 } ] }
@@ -396,7 +396,7 @@ exports['should correctly execute insert methods using crud api'] = {
396
396
db . collection ( 't2_6' ) . insertMany ( [ { c :1 } , { c :2 } , { c :3 } ] , { w :1 } , function ( err , r ) {
397
397
test . equal ( null , err ) ;
398
398
test . equal ( 3 , r . result . n ) ;
399
-
399
+
400
400
db . collection ( 't2_6' ) . bulkWrite ( [
401
401
{ insertOne : { document : { a : 1 } } }
402
402
, { updateOne : { filter : { a :2 } , update : { $set : { a :2 } } , upsert :true } }
@@ -431,7 +431,7 @@ exports['should correctly execute insert methods using crud api'] = {
431
431
db . collection ( 't2_7' ) . insertMany ( [ { c :1 } ] , { w :1 } , function ( err , r ) {
432
432
test . equal ( null , err ) ;
433
433
test . equal ( 1 , r . result . n ) ;
434
-
434
+
435
435
db . collection ( 't2_7' ) . bulkWrite ( [
436
436
{ insertOne : { a : 1 } }
437
437
, { insertMany : [ { g : 1 } , { g : 2 } ] }
@@ -465,7 +465,7 @@ exports['should correctly execute insert methods using crud api'] = {
465
465
db . collection ( 't2_8' ) . insertMany ( [ { c :1 } ] , { w :1 } , function ( err , r ) {
466
466
test . equal ( null , err ) ;
467
467
test . equal ( 1 , r . result . n ) ;
468
-
468
+
469
469
db . collection ( 't2_8' ) . bulkWrite ( [
470
470
{ insertOne : { document : { a : 1 } } }
471
471
, { updateOne : { filter : { a :2 } , update : { $set : { a :2 } } , upsert :true } }
@@ -502,7 +502,7 @@ exports['should correctly execute update methods using crud api'] = {
502
502
// Add a tag that our runner can trigger on
503
503
// in this case we are setting that node needs to be higher than 0.10.X to run
504
504
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
505
-
505
+
506
506
// The actual test we wish to run
507
507
test : function ( configuration , test ) {
508
508
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -528,7 +528,7 @@ exports['should correctly execute update methods using crud api'] = {
528
528
db . collection ( 't3_2' ) . insertMany ( [ { c :1 } ] , { w :1 } , function ( err , r ) {
529
529
test . equal ( null , err ) ;
530
530
test . equal ( 1 , r . result . n ) ;
531
-
531
+
532
532
db . collection ( 't3_2' ) . updateOne ( { a : 1 }
533
533
, { $set : { a : 1 } }
534
534
, { upsert : true } , function ( err , r ) {
@@ -543,7 +543,7 @@ exports['should correctly execute update methods using crud api'] = {
543
543
test . equal ( 1 , r . result . n ) ;
544
544
test . equal ( 1 , r . matchedCount ) ;
545
545
test . ok ( r . upsertedId == null ) ;
546
-
546
+
547
547
replaceOne ( ) ;
548
548
} ) ;
549
549
} ) ;
@@ -573,7 +573,7 @@ exports['should correctly execute update methods using crud api'] = {
573
573
574
574
test . equal ( 1 , r . matchedCount ) ;
575
575
test . ok ( r . upsertedId == null ) ;
576
-
576
+
577
577
updateMany ( ) ;
578
578
} ) ;
579
579
} ) ;
@@ -586,7 +586,7 @@ exports['should correctly execute update methods using crud api'] = {
586
586
db . collection ( 't3_4' ) . insertMany ( [ { a :1 } , { a :1 } ] , { w :1 } , function ( err , r ) {
587
587
test . equal ( null , err ) ;
588
588
test . equal ( 2 , r . result . n ) ;
589
-
589
+
590
590
db . collection ( 't3_4' ) . updateMany ( { a : 1 }
591
591
, { $set : { a : 2 } }
592
592
, { upsert : true , w : 1 } , function ( err , r ) {
@@ -601,7 +601,7 @@ exports['should correctly execute update methods using crud api'] = {
601
601
test . equal ( null , err ) ;
602
602
test . equal ( 1 , r . matchedCount ) ;
603
603
test . ok ( r . upsertedId != null ) ;
604
-
604
+
605
605
db . close ( ) ;
606
606
test . done ( ) ;
607
607
} ) ;
@@ -618,7 +618,7 @@ exports['should correctly execute remove methods using crud api'] = {
618
618
// Add a tag that our runner can trigger on
619
619
// in this case we are setting that node needs to be higher than 0.10.X to run
620
620
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
621
-
621
+
622
622
// The actual test we wish to run
623
623
test : function ( configuration , test ) {
624
624
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -632,7 +632,7 @@ exports['should correctly execute remove methods using crud api'] = {
632
632
db . collection ( 't4_1' ) . insertMany ( [ { a :1 } , { a :1 } ] , { w :1 } , function ( err , r ) {
633
633
test . equal ( null , err ) ;
634
634
test . equal ( 2 , r . result . n ) ;
635
-
635
+
636
636
db . collection ( 't4_1' ) . remove ( { a :1 } , { single :true } , function ( err , r ) {
637
637
test . equal ( null , err ) ;
638
638
test . equal ( 1 , r . result . n ) ;
@@ -655,7 +655,7 @@ exports['should correctly execute remove methods using crud api'] = {
655
655
test . equal ( null , err ) ;
656
656
test . equal ( 1 , r . result . n ) ;
657
657
test . equal ( 1 , r . deletedCount ) ;
658
-
658
+
659
659
deleteMany ( ) ;
660
660
} ) ;
661
661
} ) ;
@@ -674,7 +674,7 @@ exports['should correctly execute remove methods using crud api'] = {
674
674
test . equal ( null , err ) ;
675
675
test . equal ( 2 , r . result . n ) ;
676
676
test . equal ( 2 , r . deletedCount ) ;
677
-
677
+
678
678
db . close ( ) ;
679
679
test . done ( ) ;
680
680
} ) ;
@@ -690,7 +690,7 @@ exports['should correctly execute findAndModify methods using crud api'] = {
690
690
// Add a tag that our runner can trigger on
691
691
// in this case we are setting that node needs to be higher than 0.10.X to run
692
692
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
693
-
693
+
694
694
// The actual test we wish to run
695
695
test : function ( configuration , test ) {
696
696
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -704,7 +704,7 @@ exports['should correctly execute findAndModify methods using crud api'] = {
704
704
db . collection ( 't5_1' ) . insertMany ( [ { a :1 , b :1 } ] , { w :1 } , function ( err , r ) {
705
705
test . equal ( null , err ) ;
706
706
test . equal ( 1 , r . result . n ) ;
707
-
707
+
708
708
db . collection ( 't5_1' ) . findOneAndDelete ( { a :1 }
709
709
, { projection : { b :1 } , sort : { a :1 } }
710
710
, function ( err , r ) {
@@ -724,14 +724,14 @@ exports['should correctly execute findAndModify methods using crud api'] = {
724
724
db . collection ( 't5_2' ) . insertMany ( [ { a :1 , b :1 } ] , { w :1 } , function ( err , r ) {
725
725
test . equal ( null , err ) ;
726
726
test . equal ( 1 , r . result . n ) ;
727
-
727
+
728
728
db . collection ( 't5_2' ) . findOneAndReplace ( { a :1 }
729
729
, { c :1 , b :1 }
730
- , {
730
+ , {
731
731
projection : { b :1 , c :1 }
732
732
, sort : { a :1 }
733
733
, returnOriginal : false
734
- , upsert : true
734
+ , upsert : true
735
735
}
736
736
, function ( err , r ) {
737
737
test . equal ( null , err ) ;
@@ -751,7 +751,7 @@ exports['should correctly execute findAndModify methods using crud api'] = {
751
751
db . collection ( 't5_3' ) . insertMany ( [ { a :1 , b :1 } ] , { w :1 } , function ( err , r ) {
752
752
test . equal ( null , err ) ;
753
753
test . equal ( 1 , r . result . n ) ;
754
-
754
+
755
755
db . collection ( 't5_3' ) . findOneAndUpdate ( { a :1 }
756
756
, { $set : { d :1 } }
757
757
, {
@@ -781,7 +781,7 @@ exports['should correctly execute removeMany with no selector'] = {
781
781
// Add a tag that our runner can trigger on
782
782
// in this case we are setting that node needs to be higher than 0.10.X to run
783
783
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
784
-
784
+
785
785
// The actual test we wish to run
786
786
test : function ( configuration , test ) {
787
787
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
@@ -804,16 +804,16 @@ exports['should correctly execute crud operations with w:0'] = {
804
804
// Add a tag that our runner can trigger on
805
805
// in this case we are setting that node needs to be higher than 0.10.X to run
806
806
metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
807
-
807
+
808
808
// The actual test we wish to run
809
809
test : function ( configuration , test ) {
810
810
var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
811
811
// Establish connection to db
812
812
db . open ( function ( err , db ) {
813
813
test . equal ( null , err ) ;
814
-
814
+
815
815
var col = db . collection ( 'shouldCorrectlyExecuteInsertOneWithW0' ) ;
816
-
816
+
817
817
col . insertOne ( { a :1 } , { w :0 } , function ( err , result ) {
818
818
test . equal ( null , err ) ;
819
819
test . equal ( 1 , result . result . ok ) ;
@@ -848,4 +848,27 @@ exports['should correctly execute crud operations with w:0'] = {
848
848
} ) ;
849
849
} ) ;
850
850
}
851
- }
851
+ }
852
+
853
+ exports [ 'should correctly execute updateOne operations with w:0 and upsert' ] = {
854
+ // Add a tag that our runner can trigger on
855
+ // in this case we are setting that node needs to be higher than 0.10.X to run
856
+ metadata : { requires : { topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
857
+
858
+ // The actual test we wish to run
859
+ test : function ( configuration , test ) {
860
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
861
+ // Establish connection to db
862
+ db . open ( function ( err , db ) {
863
+ test . equal ( null , err ) ;
864
+
865
+ db . collection ( 'try' ) . updateOne ( { _id :1 } , { $set :{ x :1 } } , { upsert :true , w :0 } , function ( err , r ) {
866
+ test . equal ( null , err ) ;
867
+ test . equal ( 0 , r . upsertedCount ) ;
868
+
869
+ db . close ( ) ;
870
+ test . done ( ) ;
871
+ } ) ;
872
+ } ) ;
873
+ }
874
+ }
0 commit comments