diff options
author | Siyuan Zhou <siyuan.zhou@mongodb.com> | 2014-03-03 17:15:39 -0500 |
---|---|---|
committer | Matt Kangas <matt.kangas@mongodb.com> | 2014-03-03 22:54:14 -0500 |
commit | 93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9 (patch) | |
tree | b1be042b0d074266fb417177b33aa0f266a3f38b /jstests/update_addToSet.js | |
parent | 3660343e0b4627d2fee4afb89b74d32644d16d18 (diff) | |
download | mongo-93d8befdbac74fb965faa4d3a8ae3e60d5a7a5b9.tar.gz |
SERVER-12127 Temporarily put back jstest in order not to lose test coverage.
Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
Diffstat (limited to 'jstests/update_addToSet.js')
-rw-r--r-- | jstests/update_addToSet.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/jstests/update_addToSet.js b/jstests/update_addToSet.js new file mode 100644 index 00000000000..da930555267 --- /dev/null +++ b/jstests/update_addToSet.js @@ -0,0 +1,58 @@ + +t = db.update_addToSet1; +t.drop(); + +o = { _id : 1 , a : [ 2 , 1 ] } +t.insert( o ); + +assert.eq( o , t.findOne() , "A1" ); + +t.update( {} , { $addToSet : { a : 3 } } ); +o.a.push( 3 ); +assert.eq( o , t.findOne() , "A2" ); + +t.update( {} , { $addToSet : { a : 3 } } ); +assert.eq( o , t.findOne() , "A3" ); + +// SERVER-628 +t.update( {} , { $addToSet : { a : { $each : [ 3 , 5 , 6 ] } } } ); +o.a.push( 5 ) +o.a.push( 6 ) +assert.eq( o , t.findOne() , "B1" ) + +t.drop() +o = { _id : 1 , a : [ 3 , 5 , 6 ] } +t.insert( o ); +t.update( {} , { $addToSet : { a : { $each : [ 3 , 5 , 6 ] } } } ); +assert.eq( o , t.findOne() , "B2" ); + +t.drop(); +t.update( { _id : 1 } , { $addToSet : { a : { $each : [ 3 , 5 , 6 ] } } } , true ); +assert.eq( o , t.findOne() , "B3" ); +t.update( { _id : 1 } , { $addToSet : { a : { $each : [ 3 , 5 , 6 ] } } } , true ); +assert.eq( o , t.findOne() , "B4" ); + +// SERVER-630 +t.drop(); +t.update( { _id : 2 } , { $addToSet : { a : 3 } } , true ); +assert.eq( 1 , t.count() , "C1" ); +assert.eq( { _id : 2 , a : [ 3 ] } , t.findOne() , "C2" ); + +// SERVER-3245 +o = {_id: 1, a: [1,2]}; +t.drop(); +t.update( {_id: 1}, {$addToSet: {a: {$each: [1,2]}}}, true ); +assert.eq( o, t.findOne(), "D1" ); + +t.drop(); +t.update( {_id: 1}, {$addToSet: {a: {$each: [1,2,1,2]}}}, true ); +assert.eq( o, t.findOne(), "D2" ); + +t.drop(); +t.insert( {_id: 1} ); +t.update( {_id: 1}, {$addToSet: {a: {$each: [1,2,2,1]}}} ); +assert.eq( o, t.findOne(), "D3" ); + +t.update( {_id: 1}, {$addToSet: {a: {$each: [3,2,2,3,3]}}} ); +o.a.push( 3 ); +assert.eq( o, t.findOne(), "D4" ); |