summaryrefslogtreecommitdiff
path: root/jstests/gle/core/gle_example.js
blob: 6096f6052176d39713208f302563225aea4193c8 (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
//
// Example test for the gle core suite (used in passthroughs)
//

var coll = db.getCollection("gle_example");
coll.drop();

coll.insert({hello: "world"});
assert.eq(null, coll.getDB().getLastError());

// Error on insert.
coll.drop();
coll.insert({_id: 1});
coll.insert({_id: 1});
var gle = db.getLastErrorObj();
assert.neq(null, gle.err);

// New requests should clear gle.
coll.findOne();
gle = db.getLastErrorObj();
assert.eq(null, gle.err);

// Error on upsert.
coll.drop();
coll.insert({_id: 1});
coll.update({y: 1}, {_id: 1}, true);
gle = db.getLastErrorObj();
assert.neq(null, gle.err);