Skip to content

Commit 844d0e7

Browse files
committed
test changes
1 parent e05e34f commit 844d0e7

File tree

3 files changed

+796
-28
lines changed

3 files changed

+796
-28
lines changed

test/functional/aggregation.test.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ describe('Aggregation', function() {
484484
cursor.explain(function(err, result) {
485485
expect(err).to.be.null;
486486
expect(result.stages).to.have.lengthOf.at.least(1);
487-
expect(result.stages[0]).to.have.key('$cursor');
487+
expect(result.stages[0]).to.have.property('$cursor');
488488

489489
client.close(done);
490490
});
@@ -977,7 +977,7 @@ describe('Aggregation', function() {
977977
}
978978
});
979979

980-
it('should fail if you try to use explain flag with readConcern/writeConcern', {
980+
it('should fail if you try to use explain flag with writeConcern', {
981981
metadata: {
982982
requires: {
983983
mongodb: '>3.6.0',
@@ -987,12 +987,9 @@ describe('Aggregation', function() {
987987

988988
test: function(done) {
989989
var databaseName = this.configuration.db;
990-
var client = this.configuration.newClient(this.configuration.writeConcernMax(), {
991-
poolSize: 1
992-
});
990+
var client = this.configuration.newClient({ poolSize: 1 });
993991

994992
const testCases = [
995-
{ readConcern: { level: 'local' } },
996993
{ writeConcern: { j: true } },
997994
{ readConcern: { level: 'local' }, writeConcern: { j: true } }
998995
];

test/functional/crud_api.test.js

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,29 @@ describe('CRUD API', function() {
3535
//
3636
// Cursor
3737
// --------------------------------------------------
38-
var cursor = db.collection('t').find({});
39-
// Possible methods on the the cursor instance
40-
cursor
41-
.filter({ a: 1 })
42-
.addCursorFlag('noCursorTimeout', true)
43-
.addQueryModifier('$comment', 'some comment')
44-
.batchSize(2)
45-
.comment('some comment 2')
46-
.limit(2)
47-
.maxTimeMs(50)
48-
.project({ a: 1 })
49-
.skip(0)
50-
.sort({ a: 1 });
38+
const makeCursor = () => {
39+
// Possible methods on the the cursor instance
40+
return db
41+
.collection('t')
42+
.find({})
43+
.filter({ a: 1 })
44+
.addCursorFlag('noCursorTimeout', true)
45+
.addQueryModifier('$comment', 'some comment')
46+
.batchSize(2)
47+
.comment('some comment 2')
48+
.limit(2)
49+
.maxTimeMs(50)
50+
.project({ a: 1 })
51+
.skip(0)
52+
.sort({ a: 1 });
53+
};
5154

5255
//
5356
// Exercise count method
5457
// -------------------------------------------------
5558
var countMethod = function() {
5659
// Execute the different methods supported by the cursor
60+
const cursor = makeCursor();
5761
cursor.count(function(err, count) {
5862
test.equal(null, err);
5963
test.equal(2, count);
@@ -67,6 +71,7 @@ describe('CRUD API', function() {
6771
var eachMethod = function() {
6872
var count = 0;
6973

74+
const cursor = makeCursor();
7075
cursor.each(function(err, doc) {
7176
test.equal(null, err);
7277
if (doc) count = count + 1;
@@ -81,6 +86,7 @@ describe('CRUD API', function() {
8186
// Exercise toArray
8287
// -------------------------------------------------
8388
var toArrayMethod = function() {
89+
const cursor = makeCursor();
8490
cursor.toArray(function(err, docs) {
8591
test.equal(null, err);
8692
test.equal(2, docs.length);
@@ -92,16 +98,16 @@ describe('CRUD API', function() {
9298
// Exercise next method
9399
// -------------------------------------------------
94100
var nextMethod = function() {
95-
var clonedCursor = cursor.clone();
96-
clonedCursor.next(function(err, doc) {
101+
const cursor = makeCursor();
102+
cursor.next(function(err, doc) {
97103
test.equal(null, err);
98104
test.ok(doc != null);
99105

100-
clonedCursor.next(function(err, doc) {
106+
cursor.next(function(err, doc) {
101107
test.equal(null, err);
102108
test.ok(doc != null);
103109

104-
clonedCursor.next(function(err, doc) {
110+
cursor.next(function(err, doc) {
105111
test.equal(null, err);
106112
test.equal(null, doc);
107113
streamMethod();
@@ -115,12 +121,12 @@ describe('CRUD API', function() {
115121
// -------------------------------------------------
116122
var streamMethod = function() {
117123
var count = 0;
118-
var clonedCursor = cursor.clone();
119-
clonedCursor.on('data', function() {
124+
const cursor = makeCursor();
125+
cursor.on('data', function() {
120126
count = count + 1;
121127
});
122128

123-
clonedCursor.once('end', function() {
129+
cursor.once('end', function() {
124130
test.equal(2, count);
125131
explainMethod();
126132
});
@@ -130,8 +136,8 @@ describe('CRUD API', function() {
130136
// Explain method
131137
// -------------------------------------------------
132138
var explainMethod = function() {
133-
var clonedCursor = cursor.clone();
134-
clonedCursor.explain(function(err, result) {
139+
const cursor = makeCursor();
140+
cursor.explain(function(err, result) {
135141
test.equal(null, err);
136142
test.ok(result != null);
137143

0 commit comments

Comments
 (0)