Skip to content

Commit 44eb1be

Browse files
test fix of 3 sets of failing compression tests
1 parent 5f42896 commit 44eb1be

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

test/integration/mongodb-handshake/mongodb-handshake.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ describe('MongoDB Handshake', () => {
5555
after(() => sinon.restore());
5656

5757
it('constructs a handshake with the specified compressors', async function () {
58-
client = this.configuration.newClient({ compressors: ['snappy'] });
58+
client = this.configuration.newClient({}, { compressors: ['snappy'] });
5959
// The load-balanced mode doesn’t perform SDAM,
6060
// so `connect` doesn’t do anything unless authentication is enabled.
6161
// Force the driver to send a command to the server in the noauth mode.

test/integration/node-specific/bson-options/utf8_validation.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ describe('class MongoDBResponse', () => {
7979
describe('parsing of utf8-invalid documents with cursors', function () {
8080
let client: MongoClient;
8181
let collection: Collection;
82+
const compressionPredicate = () =>
83+
process.env.COMPRESSOR ? 'Test requires that compression is disabled' : true;
8284

8385
/**
8486
* Inserts a document with malformed utf8 bytes. This method spies on socket.write, and then waits
@@ -117,6 +119,10 @@ describe('parsing of utf8-invalid documents with cursors', function () {
117119
}
118120

119121
beforeEach(async function () {
122+
if (typeof compressionPredicate() === 'string') {
123+
this.currentTest.skipReason = compressionPredicate() as string;
124+
this.currentTest.skip();
125+
}
120126
client = this.configuration.newClient();
121127
await client.connect();
122128
const db = client.db('test');

test/integration/read-write-concern/write_concern.test.ts

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect } from 'chai';
22
import { on, once } from 'events';
3-
import { gte } from 'semver';
43
import * as sinon from 'sinon';
54

65
import {
@@ -174,6 +173,8 @@ describe('Write Concern', function () {
174173
});
175174

176175
describe('fire-and-forget protocol', function () {
176+
const compressionPredicate = () =>
177+
process.env.COMPRESSOR ? 'Test requires that compression is disabled' : true;
177178
context('when writeConcern = 0 and OP_MSG is used', function () {
178179
const writeOperations: { name: string; command: any; expectedReturnVal: any }[] = [
179180
{
@@ -270,10 +271,6 @@ describe('Write Concern', function () {
270271
let spy;
271272

272273
beforeEach(async function () {
273-
if (gte('3.6.0', this.configuration.version)) {
274-
this.currentTest.skipReason = 'Test requires OP_MSG, needs to be on MongoDB 3.6+';
275-
this.skip();
276-
}
277274
spy = sinon.spy(OpMsgRequest.prototype, 'toBin');
278275
client = this.configuration.newClient({ monitorCommands: true, w: 0 });
279276
await client.connect();
@@ -284,22 +281,34 @@ describe('Write Concern', function () {
284281
client.close();
285282
});
286283

287-
it('the request should have moreToCome bit set', async function () {
288-
await op.command(client);
289-
expect(spy.returnValues[spy.returnValues.length - 1][0][16]).to.equal(2);
290-
});
284+
it(
285+
'the request should have moreToCome bit set',
286+
{ requires: { predicate: compressionPredicate } },
287+
async function () {
288+
await op.command(client);
289+
expect(spy.returnValues[spy.returnValues.length - 1][0][16]).to.equal(2);
290+
}
291+
);
291292

292-
it('the return value of the command should be nullish', async function () {
293-
const result = await op.command(client);
294-
expect(result).to.containSubset(op.expectedReturnVal);
295-
});
293+
it(
294+
'the return value of the command should be nullish',
295+
{ requires: { predicate: compressionPredicate } },
296+
async function () {
297+
const result = await op.command(client);
298+
expect(result).to.containSubset(op.expectedReturnVal);
299+
}
300+
);
296301

297-
it('commandSucceededEvent should have reply with only {ok: 1}', async function () {
298-
const events: CommandSucceededEvent[] = [];
299-
client.on('commandSucceeded', event => events.push(event));
300-
await op.command(client);
301-
expect(events[0]).to.containSubset({ reply: { ok: 1 } });
302-
});
302+
it(
303+
'commandSucceededEvent should have reply with only {ok: 1}',
304+
{ requires: { predicate: compressionPredicate } },
305+
async function () {
306+
const events: CommandSucceededEvent[] = [];
307+
client.on('commandSucceeded', event => events.push(event));
308+
await op.command(client);
309+
expect(events[0]).to.containSubset({ reply: { ok: 1 } });
310+
}
311+
);
303312
});
304313
}
305314
});

0 commit comments

Comments
 (0)