summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/session_w0.js
blob: dd219581f43d740b42f3558beebbdd53126a6201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Explicit shell session should prohibit w: 0 writes.
 */
(function() {
    "use strict";

    const conn = MongoRunner.runMongod();
    const session = conn.startSession();
    const sessionColl = session.getDatabase("test").getCollection("foo");
    const err = assert.throws(() => {
        sessionColl.insert({x: 1}, {writeConcern: {w: 0}});
    });

    assert.includes(err.toString(),
                    "Unacknowledged writes are prohibited with sessions",
                    "wrong error message");

    session.endSession();
    MongoRunner.stopMongod(conn);
})();