summaryrefslogtreecommitdiff
path: root/jstests/core
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2014-03-14 15:21:49 -0400
committerGreg Studer <greg@10gen.com>2014-03-18 15:26:25 -0400
commit6ee3a36bdb672e0e7b893a77334e932d8d1eab8c (patch)
treeccc6bc72f2925ca398ddfd5f22f2e3840aa63d65 /jstests/core
parent4184de903c4b5bb3f698d93aa607dd06756dfe40 (diff)
downloadmongo-6ee3a36bdb672e0e7b893a77334e932d8d1eab8c.tar.gz
SERVER-13057 push shell write errors more in line with other drivers
Diffstat (limited to 'jstests/core')
-rw-r--r--jstests/core/big_object1.js2
-rw-r--r--jstests/core/bulk_api_ordered.js7
-rw-r--r--jstests/core/bulk_api_unordered.js6
-rw-r--r--jstests/core/bulk_insert.js4
-rw-r--r--jstests/core/bulk_legacy_enforce_gle.js14
-rw-r--r--jstests/core/cappeda.js2
-rw-r--r--jstests/core/geo_borders.js2
-rw-r--r--jstests/core/geo_multinest0.js2
-rw-r--r--jstests/core/geo_polygon2.js2
-rwxr-xr-xjstests/core/geo_s2index.js4
-rw-r--r--jstests/core/indexOtherNamespace.js14
-rw-r--r--jstests/core/index_big1.js2
-rw-r--r--jstests/core/indexapi.js10
-rw-r--r--jstests/core/indexi.js15
-rw-r--r--jstests/core/ns_length.js2
-rw-r--r--jstests/core/push2.js2
-rw-r--r--jstests/core/remove6.js2
-rw-r--r--jstests/core/removeb.js2
-rw-r--r--jstests/core/rename4.js2
-rw-r--r--jstests/core/storefunc.js2
-rw-r--r--jstests/core/update_dbref.js10
-rw-r--r--jstests/core/update_replace.js18
-rw-r--r--jstests/core/update_setOnInsert.js6
-rw-r--r--jstests/core/updatel.js8
-rw-r--r--jstests/core/upsert1.js2
-rw-r--r--jstests/core/write_result.js11
26 files changed, 64 insertions, 89 deletions
diff --git a/jstests/core/big_object1.js b/jstests/core/big_object1.js
index be61dbd3041..e567cf8ce93 100644
--- a/jstests/core/big_object1.js
+++ b/jstests/core/big_object1.js
@@ -23,7 +23,7 @@ if ( db.adminCommand( "buildinfo" ).bits == 64 ){
break;
}
- if ( result.hasWriteErrors() )
+ if ( result.hasWriteError() )
break;
x++;
}
diff --git a/jstests/core/bulk_api_ordered.js b/jstests/core/bulk_api_ordered.js
index fd0f528cb9c..beef9d24411 100644
--- a/jstests/core/bulk_api_ordered.js
+++ b/jstests/core/bulk_api_ordered.js
@@ -80,8 +80,9 @@ var executeTests = function() {
bulkOp.insert({b:1, a:1});
bulkOp.find({b:2}).upsert().updateOne({$set: {a:1}});
bulkOp.insert({b:3, a:2});
- var result = bulkOp.execute();
-
+ var result = assert.throws( function() { bulkOp.execute(); } );
+ assert(result instanceof BulkWriteError);
+ assert(result instanceof Error);
// Basic properties check
assert.eq(1, result.nInserted);
assert.eq(true, result.hasWriteErrors());
@@ -118,7 +119,7 @@ var executeTests = function() {
bulkOp.find({b:2}).upsert().updateOne({$set: {a:1}});
bulkOp.insert({b:4, a:3});
bulkOp.insert({b:5, a:1});
- var result = bulkOp.execute();
+ var result = assert.throws( function() { bulkOp.execute(); } );
// Basic properties check
assert.eq(1, result.nInserted);
diff --git a/jstests/core/bulk_api_unordered.js b/jstests/core/bulk_api_unordered.js
index db6c372fb76..1c8607dec37 100644
--- a/jstests/core/bulk_api_unordered.js
+++ b/jstests/core/bulk_api_unordered.js
@@ -83,7 +83,8 @@ var executeTests = function() {
bulkOp.insert({b:1, a:1});
bulkOp.find({b:2}).upsert().updateOne({$set: {a:1}});
bulkOp.insert({b:3, a:2});
- var result = bulkOp.execute();
+ var result = assert.throws( function() { bulkOp.execute(); } );
+
// Basic properties check
assert.eq(2, result.nInserted);
assert.eq(true, result.hasWriteErrors());
@@ -116,7 +117,8 @@ var executeTests = function() {
bulkOp.find({b:2}).upsert().updateOne({$set: {a:1}});
bulkOp.insert({b:4, a:3});
bulkOp.insert({b:5, a:1});
- var result = bulkOp.execute();
+ var result = assert.throws( function() { bulkOp.execute(); } );
+
// Basic properties check
assert.eq(2, result.nInserted);
assert.eq(1, result.nUpserted);
diff --git a/jstests/core/bulk_insert.js b/jstests/core/bulk_insert.js
index e26b323c6d9..e2e625e0a3c 100644
--- a/jstests/core/bulk_insert.js
+++ b/jstests/core/bulk_insert.js
@@ -3,7 +3,9 @@
var coll = db.bulkInsertTest
coll.drop()
-Random.srand( new Date().getTime() )
+var seed = new Date().getTime();
+Random.srand( seed );
+print("Seed for randomized test is " + seed);
var bulkSize = Math.floor( Random.rand() * 200 ) + 1
var numInserts = Math.floor( Random.rand() * 300 ) + 1
diff --git a/jstests/core/bulk_legacy_enforce_gle.js b/jstests/core/bulk_legacy_enforce_gle.js
index bec11749274..4efc280ab37 100644
--- a/jstests/core/bulk_legacy_enforce_gle.js
+++ b/jstests/core/bulk_legacy_enforce_gle.js
@@ -10,7 +10,7 @@ var coll = db.bulk_legacy_enforce_gle;
coll.drop();
var bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
-assert.writeOK(bulk.execute());
+assert( bulk.execute() instanceof BulkWriteResult );
var gle = db.runCommand({ getLastError: 1 });
assert(gle.ok, tojson(gle));
@@ -21,7 +21,7 @@ coll.drop();
coll.insert({ _id: 1 });
bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
-assert.writeError(bulk.execute());
+assert.throws( function() { bulk.execute(); } );
gle = db.runCommand({ getLastError: 1 });
assert(gle.ok, tojson(gle));
@@ -34,7 +34,7 @@ bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 0 });
-var res = assert.writeError(bulk.execute());
+var res = assert.throws( function() { bulk.execute(); } );
assert.eq(2, res.getWriteErrors().length);
gle = db.runCommand({ getLastError: 1 });
@@ -48,7 +48,7 @@ bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 0 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 2 });
-res = assert.writeError(bulk.execute());
+var res = assert.throws( function() { bulk.execute(); } );
assert.eq(1, res.getWriteErrors().length);
gle = db.runCommand({ getLastError: 1 });
@@ -63,7 +63,7 @@ bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 0 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 2 });
-res = assert.writeError(bulk.execute());
+res = assert.throws( function() { bulk.execute(); } );
assert.eq(1, res.getWriteErrors().length);
gle = db.runCommand({ getLastError: 1 });
@@ -77,7 +77,7 @@ bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 0 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 2 });
-res = assert.writeError(bulk.execute());
+res = assert.throws( function() { bulk.execute(); } );
assert.eq(1, res.getWriteErrors().length);
gle = db.runCommand({ getLastError: 1, w: 1 });
@@ -91,7 +91,7 @@ bulk = coll.initializeUnorderedBulkOp();
bulk.find({ none: 1 }).upsert().updateOne({ _id: 0 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 1 });
bulk.find({ none: 1 }).upsert().updateOne({ _id: 2 });
-res = assert.writeError(bulk.execute());
+res = assert.throws( function() { bulk.execute(); } );
assert.eq(1, res.getWriteErrors().length);
gle = db.runCommand({ getLastError: 1, w: 0 });
diff --git a/jstests/core/cappeda.js b/jstests/core/cappeda.js
index 3244ffae84f..4292a989511 100644
--- a/jstests/core/cappeda.js
+++ b/jstests/core/cappeda.js
@@ -14,7 +14,7 @@ function q() {
function u() {
var res = t.update( { _id : 5 } , { $set : { x : 2 } } );
- if ( res.hasWriteErrors() )
+ if ( res.hasWriteError() )
throw res;
}
diff --git a/jstests/core/geo_borders.js b/jstests/core/geo_borders.js
index 20781409b1e..32c4889eccd 100644
--- a/jstests/core/geo_borders.js
+++ b/jstests/core/geo_borders.js
@@ -27,7 +27,7 @@ assert.neq(null, res);
// Create a point index only slightly bigger than the points we have
res = t.ensureIndex( { loc : "2d" }, { max : overallMax + epsilon, min : overallMin - epsilon } );
-assert.writeOK(res);
+assert.commandWorked(res);
// ************
// Box Tests
diff --git a/jstests/core/geo_multinest0.js b/jstests/core/geo_multinest0.js
index 634d581589c..7cde4f87280 100644
--- a/jstests/core/geo_multinest0.js
+++ b/jstests/core/geo_multinest0.js
@@ -39,7 +39,7 @@ t.insert( { zip : "10001", data : [ { loc : [ [ 10, 10 ], { lat : 50, long : 50
t.insert( { zip : "10002", data : [ { loc : [ 20, 20 ], type : "home" },
{ loc : [ 50, 50 ], type : "work" } ] } )
res = t.insert({ zip: "10003", data: [{ loc: [{ x: 30, y: 30 }, [ 50, 50 ]], type: "home" }]});
-assert( !res.hasWriteErrors() );
+assert( !res.hasWriteError() );
assert.commandWorked(t.ensureIndex( { "data.loc" : "2d", zip : 1 } ));
assert.eq( 2, t.getIndexKeys().length )
diff --git a/jstests/core/geo_polygon2.js b/jstests/core/geo_polygon2.js
index c626064f153..26477651a06 100644
--- a/jstests/core/geo_polygon2.js
+++ b/jstests/core/geo_polygon2.js
@@ -247,7 +247,7 @@ for ( var test = 0; test < numTests; test++ ) {
}
var res = t.ensureIndex({ loc: "2d" }, { bits: 1 + bits, max: bounds[1], min: bounds[0] });
- assert.writeOK( res );
+ assert.commandWorked( res );
t.insert( { loc : allPointsIn } );
t.insert( { loc : allPointsOut } );
diff --git a/jstests/core/geo_s2index.js b/jstests/core/geo_s2index.js
index fea45dbb901..11d86a3bf2f 100755
--- a/jstests/core/geo_s2index.js
+++ b/jstests/core/geo_s2index.js
@@ -35,7 +35,7 @@ t.insert( {geo : somepoly, nonGeo: "somepoly" })
var res = t.ensureIndex( { geo : "2dsphere", nonGeo: 1 } );
// We have a point without any geo data. Don't error.
-assert.writeOK(res);
+assert.commandWorked(res);
res = t.find({ "geo" : { "$geoIntersects" : { "$geometry" : pointA} } });
assert.eq(res.itcount(), 3);
@@ -96,7 +96,7 @@ assert.writeOK(res);
t.drop();
t.save({loc: [0,0]})
res = t.ensureIndex({ loc: "2dsphere" }, { finestIndexedLevel: 17, coarsestIndexedLevel: 5 });
-assert.writeOK(res);
+assert.commandWorked(res);
t.drop();
t.save({loc: [0,0]})
diff --git a/jstests/core/indexOtherNamespace.js b/jstests/core/indexOtherNamespace.js
index 7df55188606..da026616cc6 100644
--- a/jstests/core/indexOtherNamespace.js
+++ b/jstests/core/indexOtherNamespace.js
@@ -7,18 +7,8 @@ otherDB.foo.insert({a:1})
assert.eq(1, otherDB.system.indexes.count());
assert.eq("BasicCursor", otherDB.foo.find({a:1}).explain().cursor);
-if (db.getMongo().writeMode() == 'commands') {
- assert.throws(function() {
- otherDB.randomNS.system.indexes.insert({ ns: "indexOtherNS.foo",
- key: { a: 1}, name: "a_1" });
- });
-}
-else {
- assert.writeError(otherDB.randomNS.system.indexes.insert({ ns: "indexOtherNS.foo",
- key: { a: 1 }, name: "a_1"}));
-}
-
-
+assert.writeError(otherDB.randomNS.system.indexes.insert({ ns: "indexOtherNS.foo",
+ key: { a: 1 }, name: "a_1"}));
// Assert that index didn't actually get built
assert.eq(1, otherDB.system.indexes.count());
diff --git a/jstests/core/index_big1.js b/jstests/core/index_big1.js
index 6fbffa4415e..dffebc351cf 100644
--- a/jstests/core/index_big1.js
+++ b/jstests/core/index_big1.js
@@ -14,7 +14,7 @@ for ( i=0; i<N; i++ ) {
bulk.insert( { a : i + .5 , x : s } );
s += "x";
}
-assert.writeError(bulk.execute());
+assert.throws( function() { bulk.execute(); } );
assert.eq( 2 , t.getIndexes().length );
diff --git a/jstests/core/indexapi.js b/jstests/core/indexapi.js
index 3e0b70ff15f..911e58e980c 100644
--- a/jstests/core/indexapi.js
+++ b/jstests/core/indexapi.js
@@ -37,12 +37,6 @@ assert( idx[1].unique , "M3" );
//printjson( idx );
// Test that attempting to create index in an invalid namespace fails.
-if (db.getMongo().writeMode() == 'commands') {
- assert.throws(function() {
- db.system.indexes.insert( { ns : "test" , key : { x : 1 } , name : "x" } );
- });
-}
-else {
- assert.writeError(db.system.indexes.insert( { ns : "test" , key : { x : 1 } , name : "x" } ));
-}
+assert.writeError(db.system.indexes.insert( { ns : "test" , key : { x : 1 } , name : "x" } ));
+
diff --git a/jstests/core/indexi.js b/jstests/core/indexi.js
index d0e77471fda..06f185fb689 100644
--- a/jstests/core/indexi.js
+++ b/jstests/core/indexi.js
@@ -5,21 +5,12 @@ t.drop();
idx = db.jstests_indexi.$_id_;
-var expectWriteError = function(func) {
- if (db.getMongo().writeMode() == 'commands') {
- assert.throws(func);
- }
- else {
- assert.writeError(func());
- }
-};
-
// Test that accessing the index namespace fails.
function checkFailingOperations() {
assert.throws(function() { idx.find().itcount(); });
- expectWriteError(function() { return idx.insert({ x: 1 }); });
- expectWriteError(function() { return idx.update({ x: 1 }, { x: 2 }); });
- expectWriteError(function() { return idx.remove({ x: 1 }); });
+ assert.writeError( idx.insert({ x: 1 }) );
+ assert.writeError( idx.update({ x: 1 }, { x: 2 }) );
+ assert.writeError( idx.remove({ x: 1 }) );
assert.commandFailed( idx.runCommand( 'compact' ) );
assert.commandFailed( idx.ensureIndex({ x: 1 }));
}
diff --git a/jstests/core/ns_length.js b/jstests/core/ns_length.js
index 203e68ead58..557e3110195 100644
--- a/jstests/core/ns_length.js
+++ b/jstests/core/ns_length.js
@@ -21,7 +21,7 @@ function canMakeCollectionWithName(name) {
var success = false;
try {
// may either throw or return an error
- success = !(myDb[name].insert({}).hasWriteErrors());
+ success = !(myDb[name].insert({}).hasWriteError());
} catch (e) {
success = false;
}
diff --git a/jstests/core/push2.js b/jstests/core/push2.js
index ae09b20fb30..2ce34b7bf9a 100644
--- a/jstests/core/push2.js
+++ b/jstests/core/push2.js
@@ -11,7 +11,7 @@ gotError = null;
for ( x=0; x<100; x++ ){
print (x + " pushes");
var res = t.update( {} , { $push : { a : s } } );
- gotError = res.hasWriteErrors();
+ gotError = res.hasWriteError();
if ( gotError )
break;
}
diff --git a/jstests/core/remove6.js b/jstests/core/remove6.js
index 838ca1c5bfd..96c5481c813 100644
--- a/jstests/core/remove6.js
+++ b/jstests/core/remove6.js
@@ -21,7 +21,7 @@ function test( n , idx ){
if ( idx )
t.ensureIndex( idx );
var res = del();
- assert( !res.hasWriteErrors() , "error deleting: " + res.toString() );
+ assert( !res.hasWriteError() , "error deleting: " + res.toString() );
assert.eq( 0 , t.count() , n + " B " + idx );
}
diff --git a/jstests/core/removeb.js b/jstests/core/removeb.js
index 230a8de012f..1e6658bd7a9 100644
--- a/jstests/core/removeb.js
+++ b/jstests/core/removeb.js
@@ -30,7 +30,7 @@ p = startParallelShell(
// Remove using the a:1 index in ascending direction.
var res = t.remove( { a:{ $gte:0 } } );
-assert( !res.hasWriteErrors(), 'The remove operation failed.' );
+assert( !res.hasWriteError(), 'The remove operation failed.' );
p();
diff --git a/jstests/core/rename4.js b/jstests/core/rename4.js
index d6ded8cbee4..85cd5e882b5 100644
--- a/jstests/core/rename4.js
+++ b/jstests/core/rename4.js
@@ -6,7 +6,7 @@ function bad( f ) {
var res = eval( f );
//Ensure error
- if (!res.hasWriteErrors()) {
+ if (!res.hasWriteError()) {
print("Error:" + res.toString());
print("Existing docs (before)")
printjson(docsBeforeUpdate);
diff --git a/jstests/core/storefunc.js b/jstests/core/storefunc.js
index b4cda6f52f0..3b5fc1ab9ab 100644
--- a/jstests/core/storefunc.js
+++ b/jstests/core/storefunc.js
@@ -7,7 +7,7 @@ s.remove({});
assert.eq( 0 , s.count() , "setup - A" );
res = s.save( { _id : "x" , value : "3" } );
-assert( !res.hasWriteErrors() , "setup - B" );
+assert( !res.hasWriteError() , "setup - B" );
assert.eq( 1 , s.count() , "setup - C" );
s.remove( { _id : "x" } );
diff --git a/jstests/core/update_dbref.js b/jstests/core/update_dbref.js
index e978a4888c5..d4c9ed7354f 100644
--- a/jstests/core/update_dbref.js
+++ b/jstests/core/update_dbref.js
@@ -5,15 +5,15 @@ t = db.jstests_update_dbref;
t.drop();
res = t.save({_id:1, a: new DBRef("a", "b")});
-assert(!res.hasWriteErrors(), "failed to save dbref");
+assert(!res.hasWriteError(), "failed to save dbref");
assert.docEq({_id:1, a: new DBRef("a", "b")}, t.findOne());
res = t.update({}, {$set: {"a.$id": 2}});
-assert(!res.hasWriteErrors(), "a.$id update");
+assert(!res.hasWriteError(), "a.$id update");
assert.docEq({_id:1, a: new DBRef("a", 2)}, t.findOne());
res = t.update({}, {$set: {"a.$ref": "b"}});
-assert(!res.hasWriteErrors(), "a.$ref update");
+assert(!res.hasWriteError(), "a.$ref update");
assert.docEq({_id:1, a: new DBRef("b", 2)}, t.findOne());
@@ -34,7 +34,7 @@ assert(/\$db/.test(res.getWriteError()), "expected bad update because of $db");
assert.docEq({_id:1, a: new DBRef("b", 2)}, t.findOne());
res = t.update({}, {$set: {"b.$id": 2}});
-assert(res.hasWriteErrors(), "b.$id update should fail -- doc:" + tojson(t.findOne()) + " result:" + res.toString());
+assert(res.hasWriteError(), "b.$id update should fail -- doc:" + tojson(t.findOne()) + " result:" + res.toString());
res = t.update({}, {$set: {"b.$ref": 2}});
-assert(res.hasWriteErrors(), "b.$ref update should fail -- doc:" + tojson(t.findOne()) + " result:" + res.toString());
+assert(res.hasWriteError(), "b.$ref update should fail -- doc:" + tojson(t.findOne()) + " result:" + res.toString());
diff --git a/jstests/core/update_replace.js b/jstests/core/update_replace.js
index ff9312baa95..ebfe2a0bd6f 100644
--- a/jstests/core/update_replace.js
+++ b/jstests/core/update_replace.js
@@ -15,38 +15,38 @@ conn._skipValidation = true;
// Should not allow "." in field names
res = t.save({_id:1, "a.a":1})
-assert(res.hasWriteErrors(), "a.a");
+assert(res.hasWriteError(), "a.a");
// Should not allow "." in field names, embedded
res = t.save({_id:1, a :{"a.a":1}})
-assert(res.hasWriteErrors(), "a: a.a");
+assert(res.hasWriteError(), "a: a.a");
// Should not allow "$"-prefixed field names, caught before "." check
res = t.save({_id:1, $a :{"a.a":1}})
-assert(res.hasWriteErrors(), "$a: a.a");
+assert(res.hasWriteError(), "$a: a.a");
// Should not allow "$"-prefixed field names
res = t.save({_id:1, $a: 1})
-assert(res.hasWriteErrors(), "$a");
+assert(res.hasWriteError(), "$a");
// _id validation checks
// Should not allow regex _id
res = t.save({_id: /a/})
-assert(res.hasWriteErrors(), "_id regex");
+assert(res.hasWriteError(), "_id regex");
// Should not allow regex _id, even if not first
res = t.save({a:2, _id: /a/})
-assert(res.hasWriteErrors(), "a _id regex");
+assert(res.hasWriteError(), "a _id regex");
// Should not allow array _id
res = t.save({_id: [9]})
-assert(res.hasWriteErrors(), "_id array");
+assert(res.hasWriteError(), "_id array");
// This is fine since _id isn't a top level field
res = t.save({a :{ _id: [9]}})
-assert(!res.hasWriteErrors(), "embedded _id array");
+assert(!res.hasWriteError(), "embedded _id array");
// This is fine since _id isn't a top level field
res = t.save({b:1, a :{ _id: [9]}})
-assert(!res.hasWriteErrors(), "b embedded _id array");
+assert(!res.hasWriteError(), "b embedded _id array");
diff --git a/jstests/core/update_setOnInsert.js b/jstests/core/update_setOnInsert.js
index 105e3493bb7..9656ac9b48d 100644
--- a/jstests/core/update_setOnInsert.js
+++ b/jstests/core/update_setOnInsert.js
@@ -36,10 +36,10 @@ dotest( true );
t.drop();
res = t.update( {_id: 1} , { $setOnInsert: { "_id.a": new Date() } } , true );
-assert(res.hasWriteErrors(), "$setOnInsert _id.a - " + res.toString() + tojson(t.findOne()));
+assert(res.hasWriteError(), "$setOnInsert _id.a - " + res.toString() + tojson(t.findOne()));
res = t.update( {"_id.a": 4} , { $setOnInsert: { "_id.b": 1 } } , true );
-assert(res.hasWriteErrors(), "$setOnInsert _id.b - " + res.toString() + tojson(t.findOne()));
+assert(res.hasWriteError(), "$setOnInsert _id.b - " + res.toString() + tojson(t.findOne()));
res = t.update( {"_id.a": 4} , { $setOnInsert: { "_id": {a:4, b:1} } } , true );
-assert(res.hasWriteErrors(), "$setOnInsert _id 3 - " + res.toString() + tojson(t.findOne()));
+assert(res.hasWriteError(), "$setOnInsert _id 3 - " + res.toString() + tojson(t.findOne()));
diff --git a/jstests/core/updatel.js b/jstests/core/updatel.js
index 7253872232c..4f7ba0cee7b 100644
--- a/jstests/core/updatel.js
+++ b/jstests/core/updatel.js
@@ -14,7 +14,7 @@ t.drop();
// The collection is empty, forcing an upsert. In this case the query has no array position match
// to substiture for the positional operator. SERVER-4713
res = t.update( {}, { $set:{ 'a.$.b':1 } }, true );
-assert( res.hasWriteErrors(), "An error is reported." );
+assert( res.hasWriteError(), "An error is reported." );
assert.eq( 0, t.count(), "No upsert occurred." );
@@ -25,14 +25,14 @@ t.save( { _id:0 } );
// Now, with an existing document, trigger an update rather than an upsert. The query has no array
// position match to substiture for the positional operator. SERVER-6669
res = t.update( {}, { $set:{ 'a.$.b':1 } } );
-assert( res.hasWriteErrors(), "An error is reported." );
+assert( res.hasWriteError(), "An error is reported." );
assert.eq( [ { _id:0 } ], t.find().toArray(), "No update occurred." );
// Now, try with an update by _id (without a query array match).
res = t.update( { _id:0 }, { $set:{ 'a.$.b':1 } } );
-assert( res.hasWriteErrors(), "An error is reported." );
+assert( res.hasWriteError(), "An error is reported." );
assert.eq( [ { _id:0 } ], t.find().toArray(), "No update occurred." );
@@ -45,5 +45,5 @@ t.save( { _id:0, a:[ { b:{ c:1 } } ] } );
// query match for the first positional operator but not the second. Note that dollar sign
// substitution for multiple positional opertors is not implemented (SERVER-831).
res = t.update( { 'a.b.c':1 }, { $set:{ 'a.$.b.$.c':2 } } );
-assert( res.hasWriteErrors(), "An error is reported" );
+assert( res.hasWriteError(), "An error is reported" );
assert.eq( [ { _id:0, a:[ { b:{ c:1 } } ] } ], t.find().toArray(), "No update occurred." );
diff --git a/jstests/core/upsert1.js b/jstests/core/upsert1.js
index 85999a189f5..f8c97e41c84 100644
--- a/jstests/core/upsert1.js
+++ b/jstests/core/upsert1.js
@@ -44,7 +44,7 @@ db.no_id.drop();
db.createCollection("no_id", {autoIndexId:false})
l = db.no_id.update({foo:1}, {$set:{a:1}}, true)
assert( l.getUpsertedId() , "H1 - " + tojson(l) );
-assert( !l.hasWriteErrors(), "H1.5 No error expected - " + tojson(l) )
+assert( !l.hasWriteError(), "H1.5 No error expected - " + tojson(l) )
assert.eq( 0, db.no_id.getIndexes().length, "H2" );
assert.eq( 1, db.no_id.count(), "H3" );
var newDoc = db.no_id.findOne();
diff --git a/jstests/core/write_result.js b/jstests/core/write_result.js
index 47f04f00b8c..c008c5ae404 100644
--- a/jstests/core/write_result.js
+++ b/jstests/core/write_result.js
@@ -143,7 +143,7 @@ coll.remove({});
printjson( result = coll.insert([{ foo : "bar" }, { foo : "baz" }]) );
assert.eq(result.nInserted, 2);
assert(!result.hasWriteErrors());
-assert(!result.getWriteConcernError());
+assert(!result.hasWriteConcernError());
assert.eq(coll.count(), 2);
//
@@ -155,7 +155,7 @@ printjson( result = coll.insert([{ _id : id, foo : "bar" },
{ _id : id, foo : "baz" }]) );
assert.eq(result.nInserted, 1);
assert(result.hasWriteErrors());
-assert(!result.getWriteConcernError());
+assert(!result.hasWriteConcernError());
assert.eq(coll.count(), 1);
//
@@ -174,16 +174,11 @@ coll.unsetWriteConcern();
// Write concern error
// NOTE: Non-throwing write concern failures require replication to trigger
coll.remove({});
-coll.setWriteConcern({ w : "invalid" });
-assert.throws( function() {
- printjson( coll.insert({ foo : "bar" }) );
-});
+assert.writeError( coll.insert({ foo : "bar" }, { writeConcern : { w : "invalid" } }) );
if (coll.getMongo().writeMode() == "commands")
assert.eq(coll.count(), 0);
else
assert.eq(coll.count(), 1);
-coll.unsetWriteConcern();
-