forked from Automattic/mongoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrash.test.js
39 lines (31 loc) · 872 Bytes
/
crash.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// GH-407
var start = require('./common')
, assert = require('assert')
, mongoose = start.mongoose
describe('crash: (gh-407)', function(){
it('test mongodb crash with invalid objectid string', function(done){
var db = mongoose.createConnection("mongodb://localhost/test-crash");
var IndexedGuy = new mongoose.Schema({
name: { type: String }
});
var Guy = db.model('Guy', IndexedGuy);
Guy.find({
_id: {
$in: [
'4e0de2a6ee47bff98000e145',
'4e137bd81a6a8e00000007ac',
'',
'4e0e2ca0795666368603d974']
}
}, function (err) {
db.close();
try {
assert.equal('Cast to ObjectId failed for value "" at path "_id"', err.message);
} catch (er) {
console.error(err);
throw er;
}
done();
});
})
})