@@ -29,38 +29,38 @@ function runTest(options) {
29
29
console . log ( JSON . stringify ( res ) ) ;
30
30
31
31
32
- if ( options . options . remove ) {
33
- res = res || { } ;
34
- if ( options . query . _id ) {
35
- res . should . have . property ( "_id" , options . query . _id ) ;
36
- }
37
- else {
38
- res . should . have . property ( "_id" ) ;
39
- }
32
+ if ( options . options . remove ) {
33
+ res = res || { } ;
34
+ if ( options . query . _id ) {
35
+ res . should . have . property ( "_id" , options . query . _id ) ;
36
+ }
37
+ else {
38
+ res . should . have . property ( "_id" ) ;
39
+ }
40
40
41
- if ( options . query . name ) {
42
- res . should . have . property ( "name" , options . query . name ) ;
43
- }
44
- else {
45
- res . should . have . property ( "name" ) ;
46
- }
47
- }
48
- else {
49
- res . should . have . property ( "value" ) ;
50
- if ( options . options . new ) {
51
- if ( options . update . $set . name ) {
52
- res . value . should . have . property ( "name" , options . update . $set . name ) ;
53
- }
54
- }
55
- else {
56
- if ( options . query . name ) {
57
- res . value . should . have . property ( "name" , options . query . name ) ;
58
- }
59
- }
60
- if ( options . query . _id ) {
61
- res . value . should . have . property ( "_id" , options . query . _id ) ;
62
- }
63
- }
41
+ if ( options . query . name ) {
42
+ res . should . have . property ( "name" , options . query . name ) ;
43
+ }
44
+ else {
45
+ res . should . have . property ( "name" ) ;
46
+ }
47
+ }
48
+ else {
49
+ res . should . have . property ( "value" ) ;
50
+ if ( options . options . new ) {
51
+ if ( options . update . $set . name ) {
52
+ res . value . should . have . property ( "name" , options . update . $set . name ) ;
53
+ }
54
+ }
55
+ else {
56
+ if ( options . query . name ) {
57
+ res . value . should . have . property ( "name" , options . query . name ) ;
58
+ }
59
+ }
60
+ if ( options . query . _id ) {
61
+ res . value . should . have . property ( "_id" , options . query . _id ) ;
62
+ }
63
+ }
64
64
done ( ) ;
65
65
} ) ;
66
66
}
@@ -123,38 +123,38 @@ function runTest(options) {
123
123
var res = await db . collection ( "testCommands2" ) . findAndModify ( options . query , options . sort || [ ] , options . update , options . options ) ;
124
124
console . log ( " " + JSON . stringify ( res ) ) ;
125
125
126
- if ( options . options . remove ) {
127
- if ( options . query . _id ) {
128
- res . should . have . property ( "_id" , options . query . _id ) ;
129
- }
130
- else {
131
- res . should . have . property ( "_id" ) ;
132
- }
126
+ if ( options . options . remove ) {
127
+ if ( options . query . _id ) {
128
+ res . should . have . property ( "_id" , options . query . _id ) ;
129
+ }
130
+ else {
131
+ res . should . have . property ( "_id" ) ;
132
+ }
133
133
134
- if ( options . query . name ) {
135
- res . should . have . property ( "name" , options . query . name ) ;
136
- }
137
- else {
138
- res . should . have . property ( "name" ) ;
139
- }
140
- }
141
- else {
142
- res . should . have . property ( "value" ) ;
143
- if ( options . options . new ) {
144
- res . value . should . have . property ( "name" , options . update . $set . name ) ;
145
- }
146
- else {
147
134
if ( options . query . name ) {
148
- res . value . should . have . property ( "name" , options . query . name ) ;
135
+ res . should . have . property ( "name" , options . query . name ) ;
136
+ }
137
+ else {
138
+ res . should . have . property ( "name" ) ;
149
139
}
150
- }
151
- if ( options . query . _id ) {
152
- res . value . should . have . property ( "_id" , options . query . _id ) ;
153
140
}
154
141
else {
155
- res . value . should . have . property ( "_id" ) ;
142
+ res . should . have . property ( "value" ) ;
143
+ if ( options . options . new ) {
144
+ res . value . should . have . property ( "name" , options . update . $set . name ) ;
145
+ }
146
+ else {
147
+ if ( options . query . name ) {
148
+ res . value . should . have . property ( "name" , options . query . name ) ;
149
+ }
150
+ }
151
+ if ( options . query . _id ) {
152
+ res . value . should . have . property ( "_id" , options . query . _id ) ;
153
+ }
154
+ else {
155
+ res . value . should . have . property ( "_id" ) ;
156
+ }
156
157
}
157
- }
158
158
159
159
}
160
160
else {
@@ -192,17 +192,17 @@ function runTest(options) {
192
192
describe ( 'Testing Simple database operations' , function ( ) {
193
193
194
194
describe ( 'Setting up db connection' , function ( ) {
195
- before ( 'Create db connection' , async function ( ) {
196
- testUtils . db = await plugins . dbConnection ( "countly" ) ;
197
- testUtils . client = testUtils . db . client ;
198
- } ) ;
195
+ before ( 'Create db connection' , async function ( ) {
196
+ testUtils . db = await plugins . dbConnection ( "countly" ) ;
197
+ testUtils . client = testUtils . db . client ;
198
+ } ) ;
199
199
it ( 'Setting db' , function ( done ) {
200
200
db = testUtils . client . db ( "countly" ) ;
201
201
done ( ) ;
202
202
} ) ;
203
203
} ) ;
204
204
205
- describe ( 'Cleanup' , function ( ) {
205
+ describe ( 'Cleanup' , function ( ) {
206
206
it ( 'should remove collection with callback' , function ( done ) {
207
207
db . collection ( "testCommands" ) . drop ( function ( err , res ) {
208
208
if ( err ) {
@@ -244,8 +244,8 @@ describe('Testing Simple database operations', function() {
244
244
describe ( 'Find and modify upsert:false,new:false' , function ( ) {
245
245
runTest ( { "op" : "findAndModify" , query : { name : "test" } , "update" : { $set : { name : "test2" } } , "options" : { new : false } } ) ;
246
246
} ) ;
247
- describe ( 'Find and modify remove:true' , function ( ) {
248
- runTest ( { "op" : "findAndModify" , query : { _id :"aaaaa" } , "update" : { } , "options" : { remove : true } } ) ;
247
+ describe ( 'Find and modify remove:true' , function ( ) {
248
+ runTest ( { "op" : "findAndModify" , query : { _id : "aaaaa" } , "update" : { } , "options" : { remove : true } } ) ;
249
249
} ) ;
250
250
} ) ;
251
251
@@ -265,10 +265,10 @@ describe('Testing Simple database operations', function() {
265
265
} ) ;
266
266
it ( "test cursor using await and going next()" , async function ( ) {
267
267
var cursor = await db . collection ( "testCommands2" ) . find ( { } ) ;
268
- var doc = await cursor . next ( ) ;
268
+ var doc = await cursor . next ( ) ;
269
269
while ( doc ) {
270
- doc . should . have . property ( "_id" ) ;
271
- doc . should . have . property ( "name" ) ;
270
+ doc . should . have . property ( "_id" ) ;
271
+ doc . should . have . property ( "name" ) ;
272
272
doc = await cursor . next ( ) ;
273
273
}
274
274
} ) ;
@@ -283,15 +283,15 @@ describe('Testing Simple database operations', function() {
283
283
console . log ( err ) ;
284
284
}
285
285
res . should . be . true ;
286
- done ( ) ;
286
+ done ( ) ;
287
287
} ) ;
288
288
289
289
} ) ;
290
290
it ( 'should remove collection with promise' , async function ( ) {
291
291
var res = await db . collection ( "testCommands2" ) . drop ( ) ;
292
292
res . should . be . true ;
293
293
} ) ;
294
- after ( 'Close db connection' , async function ( ) {
294
+ after ( 'Close db connection' , async function ( ) {
295
295
testUtils . client . close ( ) ;
296
296
} ) ;
297
297
} ) ;
0 commit comments