summaryrefslogtreecommitdiff
path: root/jstests/readonly/write_ops.js
blob: a5d43077cbc9e284d72160c65b251e0196e02514 (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
load("jstests/readonly/lib/read_only_test.js");

runReadOnlyTest(function() {
    'use strict';
    return {
        name: 'write_ops',
        load: function(writableCollection) {
            assert.writeOK(writableCollection.insert({_id: 0, x: 1}));
        },
        exec: function(readableCollection) {
            // Test that insert fails.
            assert.writeErrorWithCode(
                readableCollection.insert({x: 2}),
                ErrorCodes.IllegalOperation,
                "Expected insert to fail because database is in read-only mode");

            // Test that delete fails.
            assert.writeErrorWithCode(
                readableCollection.remove({x: 1}),
                ErrorCodes.IllegalOperation,
                "Expected remove to fail because database is in read-only mode");

            // Test that update fails.
            assert.writeErrorWithCode(
                readableCollection.update({_id: 0}, {$inc: {x: 1}}),
                ErrorCodes.IllegalOperation,
                "Expected update to fail because database is in read-only mode");
        }
    };
}());