Skip to content

Commit 4636622

Browse files
committed
Fixed breaking tests on 2.4 or earlier
1 parent c1594e3 commit 4636622

10 files changed

+230
-167
lines changed

lib/collection.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ var updateOne = function(self, filter, update, options, callback) {
646646
// Execute update
647647
updateDocuments(self, filter, update, options, function(err, r) {
648648
if(callback == null) return;
649-
if(r == null) return callback(null, null);
650649
if(err && callback) return callback(err);
651650
if(r == null) return callback(null, {result: {ok:1}});
652651
r.matchedCount = r.result.n;
@@ -887,7 +886,6 @@ var deleteMany = function(self, filter, options, callback) {
887886
options.single = false;
888887
removeDocuments(self, filter, options, function(err, r) {
889888
if(callback == null) return;
890-
if(r == null) return callback(null, null);
891889
if(err && callback) return callback(err);
892890
if(r == null) return callback(null, {result: {ok:1}});
893891
r.deletedCount = r.result.n;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
, "gleak": "0.5.0"
2828
, "mongodb-version-manager": "^0.5.0"
2929
, "mongodb-tools": "~1.0"
30+
, "co": "4.5.4"
3031
},
3132
"author": "Christian Kvalheim",
3233
"license": "Apache-2.0",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
var ES6GeneratorsSupportedFilter = function() {
2+
var serverConfig = null;
3+
4+
this.beforeStart = function(object, callback) {
5+
callback();
6+
}
7+
8+
this.filter = function(test) {
9+
if(test.metadata == null) return false;
10+
if(test.metadata.requires == null) return false;
11+
if(test.metadata.requires.generators == null) return false;
12+
if(test.metadata.requires.generators == false) return false;
13+
var check = true;
14+
15+
try {
16+
eval("(function *(){})");
17+
check = false;
18+
} catch(err) {}
19+
20+
// Do not execute the test
21+
return check;
22+
}
23+
}
24+
25+
module.exports = ES6GeneratorsSupportedFilter;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"use strict";
2+
3+
var ES6PromisesSupportedFilter = function() {
4+
var serverConfig = null;
5+
6+
this.beforeStart = function(object, callback) {
7+
callback();
8+
}
9+
10+
this.filter = function(test) {
11+
if(test.metadata == null) return false;
12+
if(test.metadata.requires == null) return false;
13+
if(test.metadata.requires.promises == null) return false;
14+
if(test.metadata.requires.promises == false) return false;
15+
var check = true;
16+
17+
try {
18+
new Promise(function() {});
19+
check = false;
20+
} catch(err) {}
21+
22+
// Do not execute the test
23+
return check;
24+
}
25+
}
26+
27+
module.exports = ES6PromisesSupportedFilter;

test/functional/crud_api_tests.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,27 +814,27 @@ exports['should correctly execute crud operations with w:0'] = {
814814

815815
var col = db.collection('shouldCorrectlyExecuteInsertOneWithW0');
816816

817-
col.insertOne({a:1}, {w:0}, function(err,result) {
817+
col.insertOne({a:1}, {w:0}, function(err, result) {
818818
test.equal(null, err);
819819
test.equal(1, result.result.ok);
820820

821-
col.insertMany([{a:1}], {w:0}, function(err,result) {
821+
col.insertMany([{a:1}], {w:0}, function(err, result) {
822822
test.equal(null, err);
823823
test.equal(1, result.result.ok);
824824

825-
col.updateOne({a:1}, {$set: {b:1}}, {w:0}, function(err,result) {
825+
col.updateOne({a:1}, {$set: {b:1}}, {w:0}, function(err, result) {
826826
test.equal(null, err);
827827
test.equal(1, result.result.ok);
828828

829-
col.updateMany({a:1}, {$set: {b:1}}, {w:0}, function(err,result) {
829+
col.updateMany({a:1}, {$set: {b:1}}, {w:0}, function(err, result) {
830830
test.equal(null, err);
831831
test.equal(1, result.result.ok);
832832

833-
col.deleteOne({a:1}, {w:0}, function(err,result) {
833+
col.deleteOne({a:1}, {w:0}, function(err, result) {
834834
test.equal(null, err);
835835
test.equal(1, result.result.ok);
836836

837-
col.deleteMany({a:1}, {w:0}, function(err,result) {
837+
col.deleteMany({a:1}, {w:0}, function(err, result) {
838838
test.equal(null, err);
839839
test.equal(1, result.result.ok);
840840

test/functional/operation_promises_example_tests.js

Lines changed: 123 additions & 123 deletions
Large diffs are not rendered by default.

test/functional/promises_collection_tests.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var f = require('util').format;
55
exports['Should correctly execute Collection.prototype.insertOne'] = {
66
metadata: {
77
requires: {
8+
promises: true,
89
node: ">0.8.0",
910
topology: ['single']
1011
}
@@ -18,13 +19,9 @@ exports['Should correctly execute Collection.prototype.insertOne'] = {
1819
? f('%s&%s', url, 'maxPoolSize=100')
1920
: f('%s?%s', url, 'maxPoolSize=100');
2021

21-
console.log("========================================================= 0")
22-
2322
MongoClient.connect(url).then(function(db) {
2423
test.equal(100, db.serverConfig.connections().length);
2524

26-
console.log("=========================================================")
27-
2825
db.collection('insertOne').insertOne({a:1}).then(function(r) {
2926

3027
db.close();

test/functional/promises_cursor_tests.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var f = require('util').format;
55
exports['Should correctly execute Collection.prototype.insertOne'] = {
66
metadata: {
77
requires: {
8+
promises: true,
89
node: ">0.8.0",
910
topology: ['single']
1011
}
@@ -18,15 +19,10 @@ exports['Should correctly execute Collection.prototype.insertOne'] = {
1819
? f('%s&%s', url, 'maxPoolSize=100')
1920
: f('%s?%s', url, 'maxPoolSize=100');
2021

21-
console.log("========================================================= 0")
22-
2322
MongoClient.connect(url).then(function(db) {
2423
test.equal(100, db.serverConfig.connections().length);
2524

26-
console.log("=========================================================")
27-
2825
db.collection('insertOne').insertOne({a:1}).then(function(r) {
29-
3026
db.close();
3127
test.done();
3228
});

test/functional/promises_db_tests.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var f = require('util').format;
55
exports['Should correctly connect with MongoClient.connect using Promise'] = {
66
metadata: {
77
requires: {
8+
promises: true,
89
node: ">0.8.0",
910
topology: ['single']
1011
}
@@ -30,6 +31,7 @@ exports['Should correctly connect with MongoClient.connect using Promise'] = {
3031
exports['Should correctly connect using Db.open and promise'] = {
3132
metadata: {
3233
requires: {
34+
promises: true,
3335
node: ">0.8.0",
3436
topology: ['single']
3537
}
@@ -48,6 +50,7 @@ exports['Should correctly connect using Db.open and promise'] = {
4850
exports['Should correctly execute ismaster using Promise'] = {
4951
metadata: {
5052
requires: {
53+
promises: true,
5154
node: ">0.8.0",
5255
topology: ['single']
5356
}
@@ -76,6 +79,7 @@ exports['Should correctly execute ismaster using Promise'] = {
7679
exports['Should correctly catch command error using Promise'] = {
7780
metadata: {
7881
requires: {
82+
promises: true,
7983
node: ">0.8.0",
8084
topology: ['single']
8185
}
@@ -106,6 +110,7 @@ exports['Should correctly catch command error using Promise'] = {
106110
exports['Should correctly createCollecton using Promise'] = {
107111
metadata: {
108112
requires: {
113+
promises: true,
109114
node: ">0.8.0",
110115
topology: ['single']
111116
}
@@ -135,6 +140,7 @@ exports['Should correctly createCollecton using Promise'] = {
135140
exports['Should correctly execute stats using Promise'] = {
136141
metadata: {
137142
requires: {
143+
promises: true,
138144
node: ">0.8.0",
139145
topology: ['single']
140146
}
@@ -162,6 +168,7 @@ exports['Should correctly execute stats using Promise'] = {
162168
exports['Should correctly execute eval using Promise'] = {
163169
metadata: {
164170
requires: {
171+
promises: true,
165172
node: ">0.8.0",
166173
topology: ['single']
167174
}
@@ -189,6 +196,7 @@ exports['Should correctly execute eval using Promise'] = {
189196
exports['Should correctly rename and drop collection using Promise'] = {
190197
metadata: {
191198
requires: {
199+
promises: true,
192200
node: ">0.8.0",
193201
topology: ['single']
194202
}
@@ -224,6 +232,7 @@ exports['Should correctly rename and drop collection using Promise'] = {
224232
exports['Should correctly drop database using Promise'] = {
225233
metadata: {
226234
requires: {
235+
promises: true,
227236
node: ">0.8.0",
228237
topology: ['single']
229238
}
@@ -251,6 +260,7 @@ exports['Should correctly drop database using Promise'] = {
251260
exports['Should correctly createCollections and call collections with Promise'] = {
252261
metadata: {
253262
requires: {
263+
promises: true,
254264
node: ">0.8.0",
255265
topology: ['single']
256266
}
@@ -286,6 +296,7 @@ exports['Should correctly createCollections and call collections with Promise']
286296
exports['Should correctly execute executeDbAdminCommand using Promise'] = {
287297
metadata: {
288298
requires: {
299+
promises: true,
289300
node: ">0.8.0",
290301
topology: ['single']
291302
}
@@ -313,6 +324,7 @@ exports['Should correctly execute executeDbAdminCommand using Promise'] = {
313324
exports['Should correctly execute creatIndex using Promise'] = {
314325
metadata: {
315326
requires: {
327+
promises: true,
316328
node: ">0.8.0",
317329
topology: ['single']
318330
}
@@ -341,6 +353,7 @@ exports['Should correctly execute creatIndex using Promise'] = {
341353
exports['Should correctly execute ensureIndex using Promise'] = {
342354
metadata: {
343355
requires: {
356+
promises: true,
344357
node: ">0.8.0",
345358
topology: ['single']
346359
}

test/runner.js

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var Runner = require('integra').Runner
77
, NodeVersionFilter = require('./filters/node_version_filter')
88
, MongoDBVersionFilter = require('./filters/mongodb_version_filter')
99
, MongoDBTopologyFilter = require('./filters/mongodb_topology_filter')
10+
, ES6PromisesSupportedFilter = require('./filters/es6_promises_supported_filter')
11+
, ES6GeneratorsSupportedFilter = require('./filters/es6_generators_supported_filter')
1012
, OSFilter = require('./filters/os_filter')
1113
, TravisFilter = require('./filters/travis_filter')
1214
, DisabledFilter = require('./filters/disabled_filter')
@@ -245,42 +247,42 @@ var testFiles =[
245247
, '/test/functional/crud_api_tests.js'
246248
, '/test/functional/reconnect_tests.js'
247249

248-
// // Promise tests
249-
// , '/test/functional/promises_db_tests.js'
250-
// , '/test/functional/promises_collection_tests.js'
251-
// , '/test/functional/promises_cursor_tests.js'
250+
// Promise tests
251+
, '/test/functional/promises_db_tests.js'
252+
, '/test/functional/promises_collection_tests.js'
253+
, '/test/functional/promises_cursor_tests.js'
252254
, '/test/functional/operation_promises_example_tests.js'
253255

254-
// // Logging tests
255-
// , '/test/functional/logger_tests.js'
256+
// Logging tests
257+
, '/test/functional/logger_tests.js'
256258

257-
// // Replicaset tests
258-
// , '/test/functional/replset_operations_tests.js'
259-
// , '/test/functional/replset_read_preference_tests.js'
260-
// , '/test/functional/replset_failover_tests.js'
261-
// , '/test/functional/replset_connection_tests.js'
259+
// Replicaset tests
260+
, '/test/functional/replset_operations_tests.js'
261+
, '/test/functional/replset_read_preference_tests.js'
262+
, '/test/functional/replset_failover_tests.js'
263+
, '/test/functional/replset_connection_tests.js'
262264

263-
// // Sharding tests
264-
// , '/test/functional/sharding_failover_tests.js'
265-
// , '/test/functional/sharding_connection_tests.js'
266-
// , '/test/functional/sharding_read_preference_tests.js'
265+
// Sharding tests
266+
, '/test/functional/sharding_failover_tests.js'
267+
, '/test/functional/sharding_connection_tests.js'
268+
, '/test/functional/sharding_read_preference_tests.js'
267269

268-
// // SSL tests
269-
// , '/test/functional/ssl_mongoclient_tests.js'
270-
// , '/test/functional/ssl_validation_tests.js'
271-
// , '/test/functional/ssl_x509_connect_tests.js'
270+
// SSL tests
271+
, '/test/functional/ssl_mongoclient_tests.js'
272+
, '/test/functional/ssl_validation_tests.js'
273+
, '/test/functional/ssl_x509_connect_tests.js'
272274

273-
// // SCRAM tests
274-
// , '/test/functional/scram_tests.js'
275+
// SCRAM tests
276+
, '/test/functional/scram_tests.js'
275277

276-
// // LDAP Tests
277-
// , '/test/functional/ldap_tests.js'
278+
// LDAP Tests
279+
, '/test/functional/ldap_tests.js'
278280

279-
// // Kerberos Tests
280-
// , '/test/functional/kerberos_tests.js'
281+
// Kerberos Tests
282+
, '/test/functional/kerberos_tests.js'
281283

282-
// // Authentication Tests
283-
// , '/test/functional/authentication_tests.js'
284+
// Authentication Tests
285+
, '/test/functional/authentication_tests.js'
284286
]
285287

286288
// Add all the tests to run
@@ -320,6 +322,10 @@ runner.plugin(new MongoDBTopologyFilter(startupOptions));
320322
runner.plugin(new OSFilter(startupOptions))
321323
// Add a Disable filter plugin
322324
runner.plugin(new DisabledFilter(startupOptions))
325+
// Add a Filter allowing us to specify that a function requires Promises
326+
runner.plugin(new ES6PromisesSupportedFilter())
327+
// Add a Filter allowing us to validate if generators are available
328+
runner.plugin(new ES6GeneratorsSupportedFilter())
323329

324330
// Exit when done
325331
runner.on('exit', function(errors, results) {

0 commit comments

Comments
 (0)