summaryrefslogtreecommitdiff
path: root/jstests/core/capped/cappeda.js
blob: 3ec0074eefe435bace0c022e9100527d93243beb (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
37
38
/**
 * @tags: [
 *   requires_capped,
 *   # capped collections connot be sharded
 *   assumes_unsharded_collection,
 * ]
 */

t = db.scan_capped_id;
t.drop();

x = t.runCommand("create", {capped: true, size: 10000});
assert(x.ok);

for (i = 0; i < 100; i++)
    t.insert({_id: i, x: 1});

function q() {
    return t.findOne({_id: 5});
}

function u() {
    var res = t.update({_id: 5}, {$set: {x: 2}});
    if (res.hasWriteError())
        throw res;
}

// SERVER-3064
// assert.throws( q , [] , "A1" );
// assert.throws( u , [] , "B1" );

t.createIndex({_id: 1});

assert.eq(1, q().x);
q();
u();

assert.eq(2, q().x);