summaryrefslogtreecommitdiff
path: root/node_modules/mongoose/test/crash.test.js
blob: 67e6c86fb18f12712e14761c885bd1be6e35242c (plain)
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
// GH-407

var start = require('./common')
  , mongoose = start.mongoose
  , should = require('should')

exports['test mongodb crash with invalid objectid string'] = function () {
  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();

    // should is acting strange
    try {
      should.strictEqual(err.message, "Invalid ObjectId");
    } catch (er) {
      console.error(err);
      throw er;
    }
  });

}