From 57b9e3b61fa08b51743d13ab5f8275534ddcf3ba Mon Sep 17 00:00:00 2001 From: Kyle Suarez Date: Mon, 12 Dec 2016 11:11:03 -0500 Subject: SERVER-25904 include expected error code in read-only write ops test --- jstests/readonly/write_ops.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/jstests/readonly/write_ops.js b/jstests/readonly/write_ops.js index bde5d231ca6..a5d43077cbc 100644 --- a/jstests/readonly/write_ops.js +++ b/jstests/readonly/write_ops.js @@ -5,17 +5,26 @@ runReadOnlyTest(function() { return { name: 'write_ops', load: function(writableCollection) { - assert.writeOK(writableCollection.insert({x: 1})); + assert.writeOK(writableCollection.insert({_id: 0, x: 1})); }, exec: function(readableCollection) { // Test that insert fails. - assert.writeError(readableCollection.insert({x: 2})); + assert.writeErrorWithCode( + readableCollection.insert({x: 2}), + ErrorCodes.IllegalOperation, + "Expected insert to fail because database is in read-only mode"); // Test that delete fails. - assert.writeError(readableCollection.remove({x: 1})); + assert.writeErrorWithCode( + readableCollection.remove({x: 1}), + ErrorCodes.IllegalOperation, + "Expected remove to fail because database is in read-only mode"); // Test that update fails. - assert.writeError(readableCollection.update({x: 1}, {$inc: {x: 1}})); + assert.writeErrorWithCode( + readableCollection.update({_id: 0}, {$inc: {x: 1}}), + ErrorCodes.IllegalOperation, + "Expected update to fail because database is in read-only mode"); } }; }()); -- cgit v1.2.1