Skip to content

Commit debbaa8

Browse files
committed
Added tests for partialFilterExpression
1 parent a7b01c7 commit debbaa8

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

test/functional/index_tests.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,3 +782,38 @@ exports['should correctly pass indexOptionDefault through to createIndexCommand'
782782
});
783783
}
784784
}
785+
786+
/**
787+
* @ignore
788+
*/
789+
exports['should correctly pass partialIndexes through to createIndexCommand'] = {
790+
metadata: { requires: { topology: ['single', 'replicaset', 'sharded', 'ssl', 'heap', 'wiredtiger'], mongodb: ">=3.1.8" } },
791+
792+
// The actual test we wish to run
793+
test: function(configuration, test) {
794+
var db = configuration.newDbInstance(configuration.writeConcernMax(), {poolSize:1});
795+
db.open(function(err, db) {
796+
var started = [], succeeded = [];
797+
798+
var listener = require('../..').instrument(function(err, instrumentations) {});
799+
listener.on('started', function(event) {
800+
if(event.commandName == 'createIndexes')
801+
started.push(event);
802+
});
803+
804+
listener.on('succeeded', function(event) {
805+
if(event.commandName == 'createIndexes')
806+
succeeded.push(event);
807+
});
808+
809+
db.collection('indexOptionDefault').createIndex({a:1}, { partialFilterExpression: {a:1} }, function(err, r) {
810+
test.equal(null, err);
811+
test.deepEqual({a:1}, started[0].command.indexes[0].partialFilterExpression);
812+
813+
listener.uninstrument();
814+
db.close();
815+
test.done();
816+
});
817+
});
818+
}
819+
}

0 commit comments

Comments
 (0)