Skip to content

Commit

Permalink
test(cursor): reduce single test run by four seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Sep 9, 2017
1 parent 43e3a17 commit ea29928
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions test/functional/cursor_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var test = require('./shared').assert;
var setupDatabase = require('./shared').setupDatabase;
var fs = require('fs');
var expect = require('chai').expect;

describe('Cursor', function() {
before(function() {
Expand Down Expand Up @@ -2285,7 +2286,9 @@ describe('Cursor', function() {
collection
) {
test.equal(null, err);
var closed = false;

var closeCount = 0;
var errorOccurred = false;

var count = 100;
// Just hammer the server
Expand All @@ -2302,16 +2305,20 @@ describe('Cursor', function() {
});

stream.on('error', function(err) {
test.ok(err != null);
expect(err).to.exist;
errorOccurred = true;
});

stream.on('end', function() {
closed = true;
});
var validator = () => {
closeCount++;
if (closeCount === 2) {
expect(errorOccurred).to.equal(true);
done();
}
};

stream.on('close', function() {
closed = true;
});
stream.on('end', validator);
stream.on('close', validator);

// Just hammer the server
for (var i = 0; i < 100; i++) {
Expand All @@ -2322,14 +2329,7 @@ describe('Cursor', function() {
});
}

setTimeout(function() {
client.close();

setTimeout(function() {
test.equal(true, closed);
done();
}, 5000);
}, 800);
setTimeout(() => client.close(), 800);
}
});
}
Expand Down

0 comments on commit ea29928

Please sign in to comment.