-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathoptional_require.test.js
More file actions
69 lines (63 loc) · 1.9 KB
/
optional_require.test.js
File metadata and controls
69 lines (63 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
'use strict';
const { expect } = require('chai');
const { existsSync } = require('fs');
const { resolve } = require('path');
const { compress } = require('../../mongodb');
const { GSSAPI } = require('../../mongodb');
const { AuthContext } = require('../../mongodb');
const { MongoDBAWS } = require('../../mongodb');
const { HostAddress } = require('../../mongodb');
function moduleExistsSync(moduleName) {
return existsSync(resolve(__dirname, `../../../node_modules/${moduleName}`));
}
describe('optionalRequire', function () {
context('Snappy', function () {
it('should error if not installed', function () {
const moduleName = 'snappy';
if (moduleExistsSync(moduleName)) {
return this.skip();
}
compress(
{
options: {
agreedCompressor: 'snappy'
}
},
Buffer.alloc(1),
error => {
expect(error).to.exist;
expect(error.message).includes('not found');
}
);
});
});
context('Kerberos', function () {
it('should error if not installed', function () {
const moduleName = 'kerberos';
if (moduleExistsSync(moduleName)) {
return this.skip();
}
const gssapi = new GSSAPI();
gssapi.auth(
new AuthContext(null, true, { hostAddress: new HostAddress('a'), credentials: true }),
error => {
expect(error).to.exist;
expect(error.message).includes('not found');
}
);
});
});
context('aws4', function () {
it('should error if not installed', function () {
const moduleName = 'aws4';
if (moduleExistsSync(moduleName)) {
return this.skip();
}
const mdbAWS = new MongoDBAWS();
mdbAWS.auth(new AuthContext({ hello: { maxWireVersion: 9 } }, true, null), error => {
expect(error).to.exist;
expect(error.message).includes('not found');
});
});
});
});