-
Type:
Improvement
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
The readConcern tests reuse quite a bit of boilerplate code. As matt.broadstone suggested, we should simplify these tests to use a format like
[
{
description: 'should set majority readConcern option for aggregate command',
operation: coll => coll.aggregate([{ $match: {} }], { readConcern: { level: 'majority' } })
].forEach(testCase => {
it(testCase.description, () => { ... });
});
and provide a helper for command monitoring, like
it('should do something with command monitoring', commandMonitoringTest(done => { ... other setup ... return collection .aggregate([{ $match: {} }], { readConcern: { level: 'majority' } }) .toArray(function(err) { const aggEvents = this.started.filter(evt => evt.name === 'aggregate'); const toCheck = aggEvents[0]; ... the rest ... }); }));
The command monitoring helper would be responsible for instrumenting before the test, maintaining a list of started/failed/succeeded events for introspection, and uninstrumenting after the test.