Skip to content

Commit 6475fd9

Browse files
committed
test: test multiple possible projection error messages
The error code for this particular error is not consistent through versions of the server, so we are stuck testing messages here.
1 parent f61842e commit 6475fd9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/functional/error_tests.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ describe('Errors', function() {
7878
});
7979
});
8080

81+
const PROJECTION_ERRORS = new Set([
82+
'Projection cannot have a mix of inclusion and exclusion.',
83+
'Cannot do exclusion on field b in inclusion projection'
84+
]);
85+
8186
it('should return an error object with message when mixing included and excluded fields', {
8287
metadata: { requires: { mongodb: '>3.0' } },
8388
test: function(done) {
@@ -86,7 +91,7 @@ describe('Errors', function() {
8691
c.insertOne({ a: 2, b: 5 }, { w: 1 }, err => {
8792
expect(err).to.not.exist;
8893
c.findOne({ a: 2 }, { fields: { a: 1, b: 0 } }, err => {
89-
expect(err.errmsg).to.equal('Projection cannot have a mix of inclusion and exclusion.');
94+
expect(PROJECTION_ERRORS).to.include(err.errmsg);
9095
done();
9196
});
9297
});
@@ -99,7 +104,7 @@ describe('Errors', function() {
99104
const db = client.db(this.configuration.db);
100105
const c = db.collection('test_error_object_should_include_message');
101106
c.findOne({}, { fields: { a: 1, b: 0 } }, err => {
102-
expect(err.errmsg).to.equal('Projection cannot have a mix of inclusion and exclusion.');
107+
expect(PROJECTION_ERRORS).to.include(err.errmsg);
103108
done();
104109
});
105110
}

0 commit comments

Comments
 (0)