Skip to content

Commit 3a39a61

Browse files
committed
Hanging test fix
1 parent 37862cc commit 3a39a61

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

test/functional/collection.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ describe('Collection', function() {
799799

800800
db.listCollections().toArray((err, documents) => {
801801
expect(err).to.not.exist;
802-
expect(documents.length > 1).to.be.true;
802+
expect(documents.length >= 1).to.be.true;
803803
let found = false;
804804

805805
documents.forEach(document => {

test/functional/mongo_client_options.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('MongoClient Options', function() {
104104
for (const connection of client.topology.s.coreTopology.connections()) {
105105
expect(connection.socketTimeout).to.deep.equal(0);
106106
}
107-
done();
107+
client.close(done);
108108
});
109109
});
110110

test/functional/operation_example.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3937,6 +3937,7 @@ describe('Operation Examples', function() {
39373937
// REMOVE-LINE var db = client.db(configuration.db);
39383938
// BEGIN
39393939
var db = client.db(configuration.db);
3940+
db.createCollection('example');
39403941
test.equal(null, err);
39413942

39423943
// Retry to get the collection, should work as it's now created

test/functional/operation_generators_example.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,7 @@ describe('Operation (Generators)', function() {
29312931
.newClient(configuration.writeConcernMax(), { poolSize: 1 })
29322932
.connect();
29332933
var db = client.db(configuration.db);
2934+
yield db.createCollection('example');
29342935
// LINE var MongoClient = require('mongodb').MongoClient,
29352936
// LINE co = require('co');
29362937
// LINE test = require('assert');

test/functional/operation_promises_example.test.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,22 +3149,28 @@ describe('Operation (Promises)', function() {
31493149
auto_reconnect: false
31503150
});
31513151

3152-
return client.connect().then(function(client) {
3153-
var db = client.db(configuration.db);
3154-
// LINE var MongoClient = require('mongodb').MongoClient,
3155-
// LINE test = require('assert');
3156-
// LINE const client = new MongoClient('mongodb://localhost:27017/test');
3157-
// LINE client.connect().then(() => {
3158-
// LINE var db = client.db('test);
3159-
// REPLACE configuration.writeConcernMax() WITH {w:1}
3160-
// REMOVE-LINE done();
3161-
// BEGIN
3162-
// Retry to get the collection, should work as it's now created
3163-
return db.collections().then(function(collections) {
3152+
return client
3153+
.connect()
3154+
.then(function(client) {
3155+
var db = client.db(configuration.db);
3156+
return db.createCollection('example');
3157+
})
3158+
.then(() => {
3159+
// LINE var MongoClient = require('mongodb').MongoClient,
3160+
// LINE test = require('assert');
3161+
// LINE const client = new MongoClient('mongodb://localhost:27017/test');
3162+
// LINE client.connect().then(() => {
3163+
// LINE var db = client.db('test);
3164+
// REPLACE configuration.writeConcernMax() WITH {w:1}
3165+
// REMOVE-LINE done();
3166+
// BEGIN
3167+
// Retry to get the collection, should work as it's now created
3168+
return client.db(configuration.db).collections();
3169+
})
3170+
.then(function(collections) {
31643171
test.ok(collections.length > 0);
31653172
return client.close();
31663173
});
3167-
});
31683174
// END
31693175
}
31703176
});

test/tools/runner/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ before(function(_done) {
8686
}
8787

8888
this.configuration = new TestConfiguration(parsedURI, context);
89-
done();
89+
client.close(done);
9090
});
9191
});
9292
});

0 commit comments

Comments
 (0)