diff options
author | Randolph Tan <randolph@10gen.com> | 2013-02-13 10:23:56 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2013-02-13 12:36:41 -0500 |
commit | 81bc3877fba8e1a5ecf60202477838602b0eceb4 (patch) | |
tree | 90c9d7d6d3fce50ad43692a2962c5b7298b7c0c6 /jstests/apply_ops2.js | |
parent | 849d5233b6e3900452a46aabbc09c0b77c1b30c2 (diff) | |
download | mongo-81bc3877fba8e1a5ecf60202477838602b0eceb4.tar.gz |
tabs -> space + formatting for apply_ops2.js
Diffstat (limited to 'jstests/apply_ops2.js')
-rw-r--r-- | jstests/apply_ops2.js | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/jstests/apply_ops2.js b/jstests/apply_ops2.js index c289f070ad3..1a5923c3465 100644 --- a/jstests/apply_ops2.js +++ b/jstests/apply_ops2.js @@ -1,6 +1,6 @@ //Test applyops upsert flag SERVER-7452 -t = db.apply_ops2; +var t = db.apply_ops2; t.drop(); assert.eq(0, t.find().count(), "test collection not empty"); @@ -10,11 +10,19 @@ t.insert({_id:1, x:"init"}); //alwaysUpsert = true print("Testing applyOps with alwaysUpsert = true"); -res = db.runCommand( { applyOps : - [ - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 1}, "o" : { $set : {x : "upsert=true existing"}}}, - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 2}, "o" : { $set : {x : "upsert=true non-existing"}}} - ], alwaysUpsert : true}); +var res = db.runCommand({ applyOps: [ + { + op: "u", + ns: t.getFullName(), + o2 : { _id: 1 }, + o: { $set: { x: "upsert=true existing" }} + }, + { + op: "u", + ns: t.getFullName(), + o2: { _id: 2 }, + o: { $set : { x: "upsert=true non-existing" }} + }], alwaysUpsert: true }); assert.eq(true, res.results[0], "upsert = true, existing doc update failed"); assert.eq(true, res.results[1], "upsert = true, nonexisting doc not upserted"); @@ -23,11 +31,19 @@ assert.eq(2, t.find().count(), "2 docs expected after upsert"); //alwaysUpsert = false print("Testing applyOps with alwaysUpsert = false"); -res = db.runCommand( { applyOps : - [ - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 1}, "o" : { $set : {x : "upsert=false existing"}}}, - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 3}, "o" : { $set : {x : "upsert=false non-existing"}}} - ], alwaysUpsert : false}); +res = db.runCommand({ applyOps: [ + { + op: "u", + ns: t.getFullName(), + o2: { _id: 1 }, + o: { $set : { x: "upsert=false existing" }} + }, + { + op: "u", + ns: t.getFullName(), + o2: { _id: 3 }, + o: { $set: { x: "upsert=false non-existing" }} + }], alwaysUpsert: false }); assert.eq(true, res.results[0], "upsert = false, existing doc update failed"); assert.eq(false, res.results[1], "upsert = false, nonexisting doc upserted"); @@ -36,11 +52,19 @@ assert.eq(2, t.find().count(), "2 docs expected after upsert failure"); //alwaysUpsert not specified, should default to true print("Testing applyOps with default alwaysUpsert"); -res = db.runCommand( { applyOps : - [ - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 1}, "o" : { $set : {x : "upsert=default existing"}}}, - {"op" : "u", "ns" : t.getFullName(), "o2" : {_id : 4}, "o" : { $set : {x : "upsert=defaults non-existing"}}} - ]}); +res = db.runCommand({ applyOps: [ + { + op: "u", + ns: t.getFullName(), + o2: { _id: 1 }, + o: { $set: { x: "upsert=default existing" }} + }, + { + op: "u", + ns: t.getFullName(), + o2: { _id: 4 }, + o: { $set: { x: "upsert=defaults non-existing" }} + }]}); assert.eq(true, res.results[0], "default upsert, existing doc update failed"); assert.eq(true, res.results[1], "default upsert, nonexisting doc not upserted"); |