@@ -15,7 +15,7 @@ exports['Should correctly execute Collection.prototype.insertOne'] = {
15
15
test : function ( configuration , test ) {
16
16
var MongoClient = configuration . require . MongoClient ;
17
17
var url = configuration . url ( ) ;
18
- url = url . indexOf ( '?' ) != - 1
18
+ url = url . indexOf ( '?' ) != - 1
19
19
? f ( '%s&%s' , url , 'maxPoolSize=100' )
20
20
: f ( '%s?%s' , url , 'maxPoolSize=100' ) ;
21
21
@@ -30,3 +30,102 @@ exports['Should correctly execute Collection.prototype.insertOne'] = {
30
30
} ) ;
31
31
}
32
32
}
33
+
34
+ exports [ 'Should correctly execute findOneAndDelete operation With Promises and no options passed in' ] = {
35
+ metadata : { requires : { promises :true , topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
36
+
37
+ // The actual test we wish to run
38
+ test : function ( configuration , test ) {
39
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
40
+ db . open ( ) . then ( function ( db ) {
41
+ // LINE var MongoClient = require('mongodb').MongoClient,
42
+ // LINE test = require('assert');
43
+ // LINE MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
44
+ // REPLACE configuration.writeConcernMax() WITH {w:1}
45
+ // REMOVE-LINE test.done();
46
+ // BEGIN
47
+ // Get the collection
48
+ var col = db . collection ( 'find_one_and_delete_with_promise_no_option' ) ;
49
+ col . insertMany ( [ { a :1 , b :1 } ] , { w :1 } ) . then ( function ( r ) {
50
+ test . equal ( 1 , r . result . n ) ;
51
+
52
+ col . findOneAndDelete ( { a :1 } ) . then ( function ( r ) {
53
+ test . equal ( 1 , r . lastErrorObject . n ) ;
54
+ test . equal ( 1 , r . value . b ) ;
55
+
56
+ db . close ( ) ;
57
+ test . done ( ) ;
58
+ } ) . catch ( function ( err ) {
59
+ console . log ( err . stack )
60
+ } ) ;
61
+ } ) ;
62
+ } ) ;
63
+ // END
64
+ }
65
+ }
66
+
67
+ exports [ 'Should correctly execute findOneAndUpate operation With Promises and no options passed in' ] = {
68
+ metadata : { requires : { promises :true , topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
69
+
70
+ // The actual test we wish to run
71
+ test : function ( configuration , test ) {
72
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
73
+ db . open ( ) . then ( function ( db ) {
74
+ // LINE var MongoClient = require('mongodb').MongoClient,
75
+ // LINE test = require('assert');
76
+ // LINE MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
77
+ // REPLACE configuration.writeConcernMax() WITH {w:1}
78
+ // REMOVE-LINE test.done();
79
+ // BEGIN
80
+ // Get the collection
81
+ var col = db . collection ( 'find_one_and_update_with_promise_no_option' ) ;
82
+ col . insertMany ( [ { a :1 , b :1 } ] , { w :1 } ) . then ( function ( r ) {
83
+ test . equal ( 1 , r . result . n ) ;
84
+
85
+ col . findOneAndUpdate ( { a :1 } , { $set :{ a :1 } } ) . then ( function ( r ) {
86
+ test . equal ( 1 , r . lastErrorObject . n ) ;
87
+ test . equal ( 1 , r . value . b ) ;
88
+
89
+ db . close ( ) ;
90
+ test . done ( ) ;
91
+ } ) . catch ( function ( err ) {
92
+ console . log ( err . stack )
93
+ } ) ;
94
+ } ) ;
95
+ } ) ;
96
+ // END
97
+ }
98
+ }
99
+
100
+ exports [ 'Should correctly execute findOneAndReplace operation With Promises and no options passed in' ] = {
101
+ metadata : { requires : { promises :true , topology : [ 'single' , 'replicaset' , 'sharded' , 'ssl' , 'heap' , 'wiredtiger' ] } } ,
102
+
103
+ // The actual test we wish to run
104
+ test : function ( configuration , test ) {
105
+ var db = configuration . newDbInstance ( configuration . writeConcernMax ( ) , { poolSize :1 , auto_reconnect :false } ) ;
106
+ db . open ( ) . then ( function ( db ) {
107
+ // LINE var MongoClient = require('mongodb').MongoClient,
108
+ // LINE test = require('assert');
109
+ // LINE MongoClient.connect('mongodb://localhost:27017/test', function(err, db) {
110
+ // REPLACE configuration.writeConcernMax() WITH {w:1}
111
+ // REMOVE-LINE test.done();
112
+ // BEGIN
113
+ // Get the collection
114
+ var col = db . collection ( 'find_one_and_replace_with_promise_no_option' ) ;
115
+ col . insertMany ( [ { a :1 , b :1 } ] , { w :1 } ) . then ( function ( r ) {
116
+ test . equal ( 1 , r . result . n ) ;
117
+
118
+ col . findOneAndReplace ( { a :1 } , { a :1 } ) . then ( function ( r ) {
119
+ test . equal ( 1 , r . lastErrorObject . n ) ;
120
+ test . equal ( 1 , r . value . b ) ;
121
+
122
+ db . close ( ) ;
123
+ test . done ( ) ;
124
+ } ) . catch ( function ( err ) {
125
+ console . log ( err . stack )
126
+ } ) ;
127
+ } ) ;
128
+ } ) ;
129
+ // END
130
+ }
131
+ }
0 commit comments