-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathoptional_require.test.ts
More file actions
60 lines (52 loc) · 1.66 KB
/
optional_require.test.ts
File metadata and controls
60 lines (52 loc) · 1.66 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
import { expect } from 'chai';
import { existsSync } from 'fs';
import { resolve } from 'path';
import { AuthContext } from '../../../src/cmap/auth/auth_provider';
import { GSSAPI } from '../../../src/cmap/auth/gssapi';
import { compress } from '../../../src/cmap/wire_protocol/compression';
import { MongoMissingDependencyError } from '../../../src/error';
import { HostAddress } from '../../../src/utils';
import { runtime } from '../../tools/utils';
function moduleExistsSync(moduleName) {
return existsSync(resolve(__dirname, `../../../node_modules/${moduleName}`));
}
describe('optionalRequire', function () {
describe('Snappy', function () {
it('should error if not installed', async function () {
const moduleName = 'snappy';
if (moduleExistsSync(moduleName)) {
return this.skip();
}
const error = await compress(
{ zlibCompressionLevel: 0, agreedCompressor: 'snappy' },
Buffer.alloc(1)
).then(
() => null,
e => e
);
expect(error).to.be.instanceOf(MongoMissingDependencyError);
});
});
describe('Kerberos', function () {
it('should error if not installed', async function () {
const moduleName = 'kerberos';
if (moduleExistsSync(moduleName)) {
return this.skip();
}
const gssapi = new GSSAPI();
const error = await gssapi
.auth(
new AuthContext(null, true, {
hostAddress: new HostAddress('a'),
credentials: true,
runtime
})
)
.then(
() => null,
e => e
);
expect(error).to.be.instanceOf(MongoMissingDependencyError);
});
});
});