Skip to content

Commit c8abdc0

Browse files
committed
test(createIndex): ensure we have one test not using options
1 parent 5461f46 commit c8abdc0

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

test/functional/collection_tests.js

+42-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
2-
var test = require('./shared').assert;
3-
var setupDatabase = require('./shared').setupDatabase;
2+
const test = require('./shared').assert;
3+
const setupDatabase = require('./shared').setupDatabase;
4+
const expect = require('chai').expect;
45

56
describe('Collection', function() {
67
before(function() {
@@ -1069,6 +1070,45 @@ describe('Collection', function() {
10691070
}
10701071
});
10711072

1073+
/**
1074+
* @ignore
1075+
*/
1076+
it('should support createIndex with no options', {
1077+
metadata: {
1078+
requires: {
1079+
mongodb: '>2.1.0',
1080+
topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger']
1081+
}
1082+
},
1083+
1084+
// The actual test we wish to run
1085+
test: function(done) {
1086+
var self = this;
1087+
var client = self.configuration.newClient(self.configuration.writeConcernMax(), {
1088+
poolSize: 1
1089+
});
1090+
1091+
client.connect(function(err, client) {
1092+
var db = client.db(self.configuration.db);
1093+
1094+
db.createCollection('create_index_without_options', {}, function(err, collection) {
1095+
collection.createIndex({ createdAt: 1 }, function(err) {
1096+
test.equal(null, err);
1097+
1098+
collection.indexInformation({ full: true }, function(err, indexes) {
1099+
test.equal(null, err);
1100+
const indexNames = indexes.map(i => i.name);
1101+
expect(indexNames).to.include('createdAt_1');
1102+
1103+
client.close();
1104+
done();
1105+
});
1106+
});
1107+
});
1108+
});
1109+
}
1110+
});
1111+
10721112
/**
10731113
* @ignore
10741114
*/

0 commit comments

Comments
 (0)