@@ -8,21 +8,21 @@ exports['Execute all read crud specification tests'] = {
8
8
test : function ( configuration , test ) {
9
9
co ( function * ( ) {
10
10
// Create db connection
11
- const MongoClient = configuration . require . MongoClient ;
12
- const db = yield MongoClient . connect ( configuration . url ( ) ) ;
11
+ var MongoClient = configuration . require . MongoClient ;
12
+ var db = yield MongoClient . connect ( configuration . url ( ) ) ;
13
13
14
14
console . log ( "== Execute CRUD read specifications" ) ;
15
15
16
16
// Read and parse all the tests cases
17
- const scenarios = fs . readdirSync ( `${ __dirname } /crud/read` ) . filter ( x => {
17
+ var scenarios = fs . readdirSync ( `${ __dirname } /crud/read` ) . filter ( x => {
18
18
return x . indexOf ( 'json' ) != - 1 ;
19
19
} ) . map ( x => {
20
20
return fs . readFileSync ( `${ __dirname } /crud/read/${ x } ` , 'utf8' ) ;
21
21
} ) . map ( x => {
22
22
return JSON . parse ( x ) ;
23
23
} ) ;
24
24
25
- for ( const scenario of scenarios ) {
25
+ for ( var scenario of scenarios ) {
26
26
yield executeScenario ( scenario , configuration , db , test ) ;
27
27
}
28
28
@@ -37,21 +37,21 @@ exports['Execute all write crud specification tests'] = {
37
37
test : function ( configuration , test ) {
38
38
co ( function * ( ) {
39
39
// Create db connection
40
- const MongoClient = configuration . require . MongoClient ;
41
- const db = yield MongoClient . connect ( configuration . url ( ) ) ;
40
+ var MongoClient = configuration . require . MongoClient ;
41
+ var db = yield MongoClient . connect ( configuration . url ( ) ) ;
42
42
43
43
console . log ( "== Execute CRUD read specifications" ) ;
44
44
45
45
// Read and parse all the tests cases
46
- const scenarios = fs . readdirSync ( `${ __dirname } /crud/write` ) . filter ( x => {
46
+ var scenarios = fs . readdirSync ( `${ __dirname } /crud/write` ) . filter ( x => {
47
47
return x . indexOf ( 'json' ) != - 1 ;
48
48
} ) . map ( x => {
49
49
return fs . readFileSync ( `${ __dirname } /crud/write/${ x } ` , 'utf8' ) ;
50
50
} ) . map ( x => {
51
51
return JSON . parse ( x ) ;
52
52
} ) ;
53
53
54
- for ( const scenario of scenarios ) {
54
+ for ( var scenario of scenarios ) {
55
55
yield executeScenario ( scenario , configuration , db , test ) ;
56
56
}
57
57
@@ -63,16 +63,16 @@ exports['Execute all write crud specification tests'] = {
63
63
function executeScenario ( scenario , configuration , db , test ) {
64
64
return new Promise ( ( resolve , reject ) => {
65
65
co ( function * ( ) {
66
- const buildInfo = yield db . admin ( ) . command ( { buildInfo :true } ) ;
67
- const mongodbVersion = buildInfo . version . split ( '-' ) . shift ( ) ;
68
- const requiredMongodbVersion = scenario . minServerVersion ;
69
- const collection = db . collection ( 'crud_spec_tests' ) ;
66
+ var buildInfo = yield db . admin ( ) . command ( { buildInfo :true } ) ;
67
+ var mongodbVersion = buildInfo . version . split ( '-' ) . shift ( ) ;
68
+ var requiredMongodbVersion = scenario . minServerVersion ;
69
+ var collection = db . collection ( 'crud_spec_tests' ) ;
70
70
71
71
// Do we satisfy semver
72
72
if ( semver . satisfies ( mongodbVersion , `>=${ requiredMongodbVersion } ` ) || ! requiredMongodbVersion ) {
73
- for ( const scenarioTest of scenario . tests ) {
74
- const description = scenarioTest . description ;
75
- const name = scenarioTest . operation . name ;
73
+ for ( var scenarioTest of scenario . tests ) {
74
+ var description = scenarioTest . description ;
75
+ var name = scenarioTest . operation . name ;
76
76
77
77
console . log ( ` execute test [${ description } ]` ) ;
78
78
@@ -91,18 +91,18 @@ function executeScenario(scenario, configuration, db, test) {
91
91
}
92
92
93
93
if ( name === 'aggregate' ) {
94
- const options = { } ;
94
+ var options = { } ;
95
95
if ( scenarioTest . operation . arguments . collation ) {
96
96
options . collation = scenarioTest . operation . arguments . collation ;
97
97
}
98
98
99
- const results = yield collection [ name ] (
99
+ var results = yield collection [ name ] (
100
100
scenarioTest . operation . arguments . pipeline , options
101
101
)
102
102
. toArray ( ) ;
103
103
104
104
if ( scenarioTest . outcome . collection ) {
105
- const collectionResults = yield db
105
+ var collectionResults = yield db
106
106
. collection ( scenarioTest . outcome . collection . name )
107
107
. find ( { } )
108
108
. toArray ( ) ;
@@ -111,99 +111,99 @@ function executeScenario(scenario, configuration, db, test) {
111
111
test . deepEqual ( scenarioTest . outcome . result , results ) ;
112
112
}
113
113
} else if ( name == 'count' ) {
114
- const arguments = scenarioTest . operation . arguments ;
115
- const filter = arguments . filter ;
116
- const options = Object . assign ( { } , arguments ) ;
114
+ var arguments = scenarioTest . operation . arguments ;
115
+ var filter = arguments . filter ;
116
+ var options = Object . assign ( { } , arguments ) ;
117
117
delete options . filter ;
118
118
119
- const result = yield collection . count ( filter , options ) ;
119
+ var result = yield collection . count ( filter , options ) ;
120
120
test . equal ( scenarioTest . outcome . result , result ) ;
121
121
} else if ( name == 'distinct' ) {
122
- const arguments = scenarioTest . operation . arguments ;
123
- const fieldName = arguments . fieldName ;
124
- const options = Object . assign ( { } , arguments ) ;
125
- const filter = arguments . filter || { } ;
122
+ var arguments = scenarioTest . operation . arguments ;
123
+ var fieldName = arguments . fieldName ;
124
+ var options = Object . assign ( { } , arguments ) ;
125
+ var filter = arguments . filter || { } ;
126
126
delete options . fieldName ;
127
127
delete options . filter ;
128
128
129
- const result = yield collection . distinct ( fieldName , filter , options ) ;
129
+ var result = yield collection . distinct ( fieldName , filter , options ) ;
130
130
test . deepEqual ( scenarioTest . outcome . result , result ) ;
131
131
} else if ( name == 'find' ) {
132
- const arguments = scenarioTest . operation . arguments ;
133
- const filter = arguments . filter ;
134
- const options = Object . assign ( { } , arguments ) ;
132
+ var arguments = scenarioTest . operation . arguments ;
133
+ var filter = arguments . filter ;
134
+ var options = Object . assign ( { } , arguments ) ;
135
135
delete options . filter ;
136
136
137
- const results = yield collection . find ( filter , options ) . toArray ( ) ;
137
+ var results = yield collection . find ( filter , options ) . toArray ( ) ;
138
138
test . deepEqual ( scenarioTest . outcome . result , results ) ;
139
139
} else if ( name == 'deleteMany' || name == 'deleteOne' ) {
140
140
// Unpack the scenario test
141
- const arguments = scenarioTest . operation . arguments ;
142
- const filter = arguments . filter ;
143
- const options = Object . assign ( { } , arguments ) ;
141
+ var arguments = scenarioTest . operation . arguments ;
142
+ var filter = arguments . filter ;
143
+ var options = Object . assign ( { } , arguments ) ;
144
144
delete options . filter ;
145
145
146
146
// Get the results
147
- const result = yield collection [ scenarioTest . operation . name ] ( filter , options ) ;
147
+ var result = yield collection [ scenarioTest . operation . name ] ( filter , options ) ;
148
148
149
149
// Go over the results
150
- for ( const name in scenarioTest . outcome . result ) {
150
+ for ( var name in scenarioTest . outcome . result ) {
151
151
test . equal ( scenarioTest . outcome . result [ name ] , result [ name ] ) ;
152
152
}
153
153
154
154
if ( scenarioTest . outcome . collection ) {
155
- const results = yield collection . find ( { } ) . toArray ( ) ;
155
+ var results = yield collection . find ( { } ) . toArray ( ) ;
156
156
test . deepEqual ( scenarioTest . outcome . collection . data , results ) ;
157
157
}
158
158
} else if ( name == 'replaceOne' ) {
159
159
// Unpack the scenario test
160
- const arguments = scenarioTest . operation . arguments ;
161
- const filter = arguments . filter ;
162
- const replacement = arguments . replacement ;
163
- const options = Object . assign ( { } , arguments ) ;
160
+ var arguments = scenarioTest . operation . arguments ;
161
+ var filter = arguments . filter ;
162
+ var replacement = arguments . replacement ;
163
+ var options = Object . assign ( { } , arguments ) ;
164
164
delete options . filter ;
165
165
delete options . replacement ;
166
166
167
167
// Get the results
168
- const result = yield collection [ scenarioTest . operation . name ] ( filter , replacement , options ) ;
168
+ var result = yield collection [ scenarioTest . operation . name ] ( filter , replacement , options ) ;
169
169
170
170
// Go over the results
171
- for ( const name in scenarioTest . outcome . result ) {
171
+ for ( var name in scenarioTest . outcome . result ) {
172
172
test . equal ( scenarioTest . outcome . result [ name ] , result [ name ] ) ;
173
173
}
174
174
175
175
if ( scenarioTest . outcome . collection ) {
176
- const results = yield collection . find ( { } ) . toArray ( ) ;
176
+ var results = yield collection . find ( { } ) . toArray ( ) ;
177
177
test . deepEqual ( scenarioTest . outcome . collection . data , results ) ;
178
178
}
179
179
} else if ( name == 'updateOne' || name == 'updateMany' ) {
180
180
// Unpack the scenario test
181
- const arguments = scenarioTest . operation . arguments ;
182
- const filter = arguments . filter ;
183
- const update = arguments . update ;
184
- const options = Object . assign ( { } , arguments ) ;
181
+ var arguments = scenarioTest . operation . arguments ;
182
+ var filter = arguments . filter ;
183
+ var update = arguments . update ;
184
+ var options = Object . assign ( { } , arguments ) ;
185
185
delete options . filter ;
186
186
delete options . update ;
187
187
188
188
// Get the results
189
- const result = yield collection [ scenarioTest . operation . name ] ( filter , update , options ) ;
189
+ var result = yield collection [ scenarioTest . operation . name ] ( filter , update , options ) ;
190
190
191
191
// Go over the results
192
- for ( const name in scenarioTest . outcome . result ) {
192
+ for ( var name in scenarioTest . outcome . result ) {
193
193
test . equal ( scenarioTest . outcome . result [ name ] , result [ name ] ) ;
194
194
}
195
195
196
196
if ( scenarioTest . outcome . collection ) {
197
- const results = yield collection . find ( { } ) . toArray ( ) ;
197
+ var results = yield collection . find ( { } ) . toArray ( ) ;
198
198
test . deepEqual ( scenarioTest . outcome . collection . data , results ) ;
199
199
}
200
200
} else if ( name == 'findOneAndReplace'
201
201
|| name == 'findOneAndUpdate' || name == 'findOneAndDelete' ) {
202
202
// Unpack the scenario test
203
- const arguments = scenarioTest . operation . arguments ;
204
- const filter = arguments . filter ;
205
- const second = arguments . update || arguments . replacement ;
206
- const options = Object . assign ( { } , arguments ) ;
203
+ var arguments = scenarioTest . operation . arguments ;
204
+ var filter = arguments . filter ;
205
+ var second = arguments . update || arguments . replacement ;
206
+ var options = Object . assign ( { } , arguments ) ;
207
207
if ( options . returnDocument ) {
208
208
options . returnOriginal = options . returnDocument == 'After' ? false : true ;
209
209
}
@@ -224,7 +224,7 @@ function executeScenario(scenario, configuration, db, test) {
224
224
}
225
225
226
226
if ( scenarioTest . outcome . collection ) {
227
- const results = yield collection . find ( { } ) . toArray ( ) ;
227
+ var results = yield collection . find ( { } ) . toArray ( ) ;
228
228
test . deepEqual ( scenarioTest . outcome . collection . data , results ) ;
229
229
}
230
230
}
@@ -233,7 +233,7 @@ function executeScenario(scenario, configuration, db, test) {
233
233
234
234
resolve ( ) ;
235
235
} ) . catch ( err => {
236
- console . log ( err )
236
+ console . log ( err . stack )
237
237
reject ( err ) ;
238
238
} ) ;
239
239
} ) ;
0 commit comments