Skip to content

Commit a9c4b3a

Browse files
committed
test: fix remaining collation tests
1 parent edb9953 commit a9c4b3a

File tree

1 file changed

+0
-241
lines changed

1 file changed

+0
-241
lines changed

test/functional/collations.test.js

-241
Original file line numberDiff line numberDiff line change
@@ -393,77 +393,6 @@ describe('Collation', function () {
393393
}
394394
});
395395

396-
it('Fail due to no support for collation', {
397-
metadata: { requires: { generators: true, topology: 'single' } },
398-
399-
test: function () {
400-
const configuration = this.configuration;
401-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
402-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
403-
404-
testContext.server.setMessageHandler(request => {
405-
const doc = request.document;
406-
if (doc.ismaster || doc.hello) {
407-
request.reply(primary[0]);
408-
} else if (doc.find) {
409-
request.reply({ ok: 1 });
410-
} else if (doc.endSessions) {
411-
request.reply({ ok: 1 });
412-
}
413-
});
414-
415-
return client.connect().then(() => {
416-
const db = client.db(configuration.db);
417-
418-
return db
419-
.collection('test')
420-
.findOne({ a: 1 }, { collation: { caseLevel: true } })
421-
.then(() => Promise.reject('this test should fail'))
422-
.catch(err => {
423-
expect(err).to.exist;
424-
expect(err.message).to.match(/does not support collation/);
425-
return client.close();
426-
});
427-
});
428-
}
429-
});
430-
431-
it('Fail command due to no support for collation', {
432-
metadata: { requires: { generators: true, topology: 'single' } },
433-
test: function () {
434-
const configuration = this.configuration;
435-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
436-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
437-
438-
testContext.server.setMessageHandler(request => {
439-
var doc = request.document;
440-
if (doc.ismaster || doc.hello) {
441-
request.reply(primary[0]);
442-
} else if (doc.find) {
443-
request.reply({ ok: 1 });
444-
} else if (doc.endSessions) {
445-
request.reply({ ok: 1 });
446-
}
447-
});
448-
449-
return client.connect().then(() => {
450-
const db = client.db(configuration.db);
451-
452-
return db
453-
.command({ count: 'test', query: {}, collation: { caseLevel: true } })
454-
.then(() => Promise.reject('should not succeed'))
455-
.catch(err => {
456-
expect(err).to.exist;
457-
expect(err.message).to.equal(
458-
`Server ${testContext.server.uri()} does not support collation`
459-
);
460-
461-
return client.close();
462-
});
463-
});
464-
}
465-
});
466-
467396
it('Successfully pass through collation to bulkWrite command', {
468397
metadata: { requires: { generators: true, topology: 'single' } },
469398
test: function () {
@@ -518,107 +447,6 @@ describe('Collation', function () {
518447
}
519448
});
520449

521-
it('Successfully fail bulkWrite due to unsupported collation in update', {
522-
metadata: { requires: { generators: true, topology: 'single' } },
523-
test: function () {
524-
const configuration = this.configuration;
525-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
526-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
527-
528-
testContext.server.setMessageHandler(request => {
529-
const doc = request.document;
530-
if (doc.ismaster || doc.hello) {
531-
request.reply(primary[0]);
532-
} else if (doc.update) {
533-
request.reply({ ok: 1 });
534-
} else if (doc.delete) {
535-
request.reply({ ok: 1 });
536-
} else if (doc.endSessions) {
537-
request.reply({ ok: 1 });
538-
}
539-
});
540-
541-
return client.connect().then(() => {
542-
const db = client.db(configuration.db);
543-
544-
return db
545-
.collection('test')
546-
.bulkWrite(
547-
[
548-
{
549-
updateOne: {
550-
filter: { a: 2 },
551-
update: { $set: { a: 2 } },
552-
upsert: true,
553-
collation: { caseLevel: true }
554-
}
555-
},
556-
{ deleteOne: { filter: { c: 1 } } }
557-
],
558-
{ ordered: true }
559-
)
560-
.then(() => {
561-
throw new Error('should not succeed');
562-
})
563-
.catch(err => {
564-
expect(err).to.exist;
565-
expect(err.message).to.match(/does not support collation/);
566-
})
567-
.then(() => client.close());
568-
});
569-
}
570-
});
571-
572-
it('Successfully fail bulkWrite due to unsupported collation in delete', {
573-
metadata: { requires: { generators: true, topology: 'single' } },
574-
test: function () {
575-
const configuration = this.configuration;
576-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
577-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
578-
579-
testContext.server.setMessageHandler(request => {
580-
const doc = request.document;
581-
if (doc.ismaster || doc.hello) {
582-
request.reply(primary[0]);
583-
} else if (doc.update) {
584-
request.reply({ ok: 1 });
585-
} else if (doc.delete) {
586-
request.reply({ ok: 1 });
587-
} else if (doc.endSessions) {
588-
request.reply({ ok: 1 });
589-
}
590-
});
591-
592-
return client.connect().then(() => {
593-
const db = client.db(configuration.db);
594-
595-
return db
596-
.collection('test')
597-
.bulkWrite(
598-
[
599-
{
600-
updateOne: {
601-
filter: { a: 2 },
602-
update: { $set: { a: 2 } },
603-
upsert: true
604-
}
605-
},
606-
{ deleteOne: { filter: { c: 1 }, collation: { caseLevel: true } } }
607-
],
608-
{ ordered: true }
609-
)
610-
.then(() => {
611-
throw new Error('should not succeed');
612-
})
613-
.catch(err => {
614-
expect(err).to.exist;
615-
expect(err.message).to.match(/does not support collation/);
616-
})
617-
.then(() => client.close());
618-
});
619-
}
620-
});
621-
622450
it('Successfully create index with collation', {
623451
metadata: { requires: { generators: true, topology: 'single' } },
624452
test: function () {
@@ -657,75 +485,6 @@ describe('Collation', function () {
657485
}
658486
});
659487

660-
it('Fail to create index with collation due to no capabilities', {
661-
metadata: { requires: { generators: true, topology: 'single' } },
662-
663-
test: function () {
664-
const configuration = this.configuration;
665-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
666-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
667-
668-
testContext.server.setMessageHandler(request => {
669-
const doc = request.document;
670-
if (doc.ismaster || doc.hello) {
671-
request.reply(primary[0]);
672-
} else if (doc.createIndexes) {
673-
request.reply({ ok: 1 });
674-
} else if (doc.endSessions) {
675-
request.reply({ ok: 1 });
676-
}
677-
});
678-
679-
return client.connect().then(() => {
680-
const db = client.db(configuration.db);
681-
682-
return db
683-
.collection('test')
684-
.createIndex({ a: 1 }, { collation: { caseLevel: true } })
685-
.then(() => Promise.reject('should not succeed'))
686-
.catch(err => {
687-
expect(err).to.exist;
688-
expect(err.message).to.match(/does not support collation$/);
689-
})
690-
.then(() => client.close());
691-
});
692-
}
693-
});
694-
695-
it('Fail to create indexs with collation due to no capabilities', {
696-
metadata: { requires: { generators: true, topology: 'single' } },
697-
698-
test: function () {
699-
const configuration = this.configuration;
700-
const client = configuration.newClient(`mongodb://${testContext.server.uri()}/test`);
701-
const primary = [Object.assign({}, mock.DEFAULT_ISMASTER, { maxWireVersion: 4 })];
702-
703-
testContext.server.setMessageHandler(request => {
704-
const doc = request.document;
705-
if (doc.ismaster || doc.hello) {
706-
request.reply(primary[0]);
707-
} else if (doc.createIndexes) {
708-
request.reply({ ok: 1 });
709-
} else if (doc.endSessions) {
710-
request.reply({ ok: 1 });
711-
}
712-
});
713-
714-
return client.connect().then(() => {
715-
const db = client.db(configuration.db);
716-
717-
return db
718-
.collection('test')
719-
.createIndexes([{ key: { a: 1 }, collation: { caseLevel: true } }])
720-
.then(() => Promise.reject('should not succeed'))
721-
.catch(err => {
722-
expect(err.message).to.match(/does not support collation$/);
723-
return client.close();
724-
});
725-
});
726-
}
727-
});
728-
729488
it('cursor count method should return the correct number when used with collation set', {
730489
metadata: { requires: { mongodb: '>=3.4.0' } },
731490
test: function (done) {

0 commit comments

Comments
 (0)