-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
write_concern.test.js
58 lines (53 loc) · 1.94 KB
/
write_concern.test.js
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
'use strict';
const chai = require('chai');
const expect = chai.expect;
const TestRunnerContext = require('./spec-runner').TestRunnerContext;
const generateTopologyTests = require('./spec-runner').generateTopologyTests;
const loadSpecTests = require('../spec').loadSpecTests;
const { withMonitoredClient } = require('./shared');
describe('Write Concern', function() {
describe('spec tests', function() {
const testContext = new TestRunnerContext();
const testSuites = loadSpecTests('read-write-concern/operation');
after(() => testContext.teardown());
before(function() {
return testContext.setup(this.configuration);
});
generateTopologyTests(testSuites, testContext);
});
// TODO - implement `read-write-concern/connection-string` spec tests
describe('test journal connection string option', function() {
const dbOptions = { journal: true };
const serverOptions = { j: true };
function writeConcernJournalOptionTest(client, events, done) {
expect(client).to.have.nested.property('s.options');
const clientOptions = client.s.options;
expect(clientOptions).to.containSubset({ j: true });
client
.db('test')
.collection('test')
.insertOne({ a: 1 }, (err, result) => {
expect(err).to.not.exist;
expect(result).to.exist;
expect(events)
.to.be.an('array')
.with.lengthOf(1);
expect(events[0]).to.containSubset({
commandName: 'insert',
command: {
writeConcern: { j: true }
}
});
done();
});
}
it(
'should set write concern with journal=true connection string option',
withMonitoredClient('insert', { dbOptions }, writeConcernJournalOptionTest)
);
it(
'should set write concern with j: true client option',
withMonitoredClient('insert', { serverOptions }, writeConcernJournalOptionTest)
);
});
});