Skip to content

Commit

Permalink
test: fix remaining collation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Oct 28, 2021
1 parent edb9953 commit a9c4b3a
Showing 1 changed file with 0 additions and 241 deletions.
241 changes: 0 additions & 241 deletions test/functional/collations.test.js
Expand Up @@ -393,77 +393,6 @@ describe('Collation', function () {
}
});

it('Fail due to no support for collation', {
metadata: { requires: { generators: true, topology: 'single' } },

test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
const doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.find) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.collection('test')
.findOne({ a: 1 }, { collation: { caseLevel: true } })
.then(() => Promise.reject('this test should fail'))
.catch(err => {
expect(err).to.exist;
expect(err.message).to.match(/does not support collation/);
return client.close();
});
});
}
});

it('Fail command due to no support for collation', {
metadata: { requires: { generators: true, topology: 'single' } },
test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
var doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.find) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.command({ count: 'test', query: {}, collation: { caseLevel: true } })
.then(() => Promise.reject('should not succeed'))
.catch(err => {
expect(err).to.exist;
expect(err.message).to.equal(
`Server ${testContext.server.uri()} does not support collation`
);

return client.close();
});
});
}
});

it('Successfully pass through collation to bulkWrite command', {
metadata: { requires: { generators: true, topology: 'single' } },
test: function () {
Expand Down Expand Up @@ -518,107 +447,6 @@ describe('Collation', function () {
}
});

it('Successfully fail bulkWrite due to unsupported collation in update', {
metadata: { requires: { generators: true, topology: 'single' } },
test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
const doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.update) {
request.reply({ ok: 1 });
} else if (doc.delete) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.collection('test')
.bulkWrite(
[
{
updateOne: {
filter: { a: 2 },
update: { $set: { a: 2 } },
upsert: true,
collation: { caseLevel: true }
}
},
{ deleteOne: { filter: { c: 1 } } }
],
{ ordered: true }
)
.then(() => {
throw new Error('should not succeed');
})
.catch(err => {
expect(err).to.exist;
expect(err.message).to.match(/does not support collation/);
})
.then(() => client.close());
});
}
});

it('Successfully fail bulkWrite due to unsupported collation in delete', {
metadata: { requires: { generators: true, topology: 'single' } },
test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
const doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.update) {
request.reply({ ok: 1 });
} else if (doc.delete) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.collection('test')
.bulkWrite(
[
{
updateOne: {
filter: { a: 2 },
update: { $set: { a: 2 } },
upsert: true
}
},
{ deleteOne: { filter: { c: 1 }, collation: { caseLevel: true } } }
],
{ ordered: true }
)
.then(() => {
throw new Error('should not succeed');
})
.catch(err => {
expect(err).to.exist;
expect(err.message).to.match(/does not support collation/);
})
.then(() => client.close());
});
}
});

it('Successfully create index with collation', {
metadata: { requires: { generators: true, topology: 'single' } },
test: function () {
Expand Down Expand Up @@ -657,75 +485,6 @@ describe('Collation', function () {
}
});

it('Fail to create index with collation due to no capabilities', {
metadata: { requires: { generators: true, topology: 'single' } },

test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
const doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.createIndexes) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.collection('test')
.createIndex({ a: 1 }, { collation: { caseLevel: true } })
.then(() => Promise.reject('should not succeed'))
.catch(err => {
expect(err).to.exist;
expect(err.message).to.match(/does not support collation$/);
})
.then(() => client.close());
});
}
});

it('Fail to create indexs with collation due to no capabilities', {
metadata: { requires: { generators: true, topology: 'single' } },

test: function () {
const configuration = this.configuration;
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];

testContext.server.setMessageHandler(request => {
const doc = request.document;
if (doc.ismaster || doc.hello) {
request.reply(primary[0]);
} else if (doc.createIndexes) {
request.reply({ ok: 1 });
} else if (doc.endSessions) {
request.reply({ ok: 1 });
}
});

return client.connect().then(() => {
const db = client.db(configuration.db);

return db
.collection('test')
.createIndexes([{ key: { a: 1 }, collation: { caseLevel: true } }])
.then(() => Promise.reject('should not succeed'))
.catch(err => {
expect(err.message).to.match(/does not support collation$/);
return client.close();
});
});
}
});

it('cursor count method should return the correct number when used with collation set', {
metadata: { requires: { mongodb: '>=3.4.0' } },
test: function (done) {
Expand Down

0 comments on commit a9c4b3a

Please sign in to comment.