1
1
import { expect } from 'chai' ;
2
2
import { on , once } from 'events' ;
3
- import { gte } from 'semver' ;
4
3
import * as sinon from 'sinon' ;
5
4
6
5
import {
@@ -174,6 +173,8 @@ describe('Write Concern', function () {
174
173
} ) ;
175
174
176
175
describe ( 'fire-and-forget protocol' , function ( ) {
176
+ const compressionPredicate = ( ) =>
177
+ process . env . COMPRESSOR ? 'Test requires that compression is disabled' : true ;
177
178
context ( 'when writeConcern = 0 and OP_MSG is used' , function ( ) {
178
179
const writeOperations : { name : string ; command : any ; expectedReturnVal : any } [ ] = [
179
180
{
@@ -270,10 +271,6 @@ describe('Write Concern', function () {
270
271
let spy ;
271
272
272
273
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
- }
277
274
spy = sinon . spy ( OpMsgRequest . prototype , 'toBin' ) ;
278
275
client = this . configuration . newClient ( { monitorCommands : true , w : 0 } ) ;
279
276
await client . connect ( ) ;
@@ -284,22 +281,34 @@ describe('Write Concern', function () {
284
281
client . close ( ) ;
285
282
} ) ;
286
283
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
+ ) ;
291
292
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
+ ) ;
296
301
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
+ ) ;
303
312
} ) ;
304
313
}
305
314
} ) ;
0 commit comments