summaryrefslogtreecommitdiff
path: root/dbtests
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-09-29 10:10:10 -0700
committerAaron <aaron@10gen.com>2010-09-29 11:16:25 -0700
commit5e538ccb8ab0d99129c3b5c9316f2b25e877d3cf (patch)
tree8304b2ec277680d14c0a8c7b24ae270c965b3471 /dbtests
parent2a4c95a3f44b12968f819e77799c8b0af9434625 (diff)
downloadmongo-5e538ccb8ab0d99129c3b5c9316f2b25e877d3cf.tar.gz
SERVER-394 implement rename modifier
Diffstat (limited to 'dbtests')
-rw-r--r--dbtests/repltests.cpp54
1 files changed, 53 insertions, 1 deletions
diff --git a/dbtests/repltests.cpp b/dbtests/repltests.cpp
index a190dc88b12..4ae78cd8a96 100644
--- a/dbtests/repltests.cpp
+++ b/dbtests/repltests.cpp
@@ -955,8 +955,57 @@ namespace ReplTests {
}
};
-
+ class Rename : public Base {
+ public:
+ void doIt() const {
+ client()->update( ns(), BSON( "_id" << 0 ), fromjson( "{$rename:{a:'b'}}" ) );
+ client()->update( ns(), BSON( "_id" << 0 ), fromjson( "{$set:{a:50}}" ) );
+ }
+ using ReplTests::Base::check;
+ void check() const {
+ ASSERT_EQUALS( 1, count() );
+ check( BSON( "_id" << 0 << "a" << 50 << "b" << 3 ) , one( fromjson( "{'_id':0}" ) ) );
+ }
+ void reset() const {
+ deleteAll( ns() );
+ insert( fromjson( "{'_id':0,a:3}" ) );
+ }
+ };
+ class RenameOverwrite : public Base {
+ public:
+ void doIt() const {
+ client()->update( ns(), BSON( "_id" << 0 ), fromjson( "{$rename:{a:'b'}}" ) );
+ client()->update( ns(), BSON( "_id" << 0 ), fromjson( "{$set:{a:50}}" ) );
+ }
+ using ReplTests::Base::check;
+ void check() const {
+ ASSERT_EQUALS( 1, count() );
+ check( BSON( "_id" << 0 << "a" << 50 << "b" << 3 ) , one( fromjson( "{'_id':0}" ) ) );
+ }
+ void reset() const {
+ deleteAll( ns() );
+ insert( fromjson( "{'_id':0,a:3,b:100}" ) );
+ }
+ };
+
+ class NoRename : public Base {
+ public:
+ void doIt() const {
+ client()->update( ns(), BSON( "_id" << 0 ), fromjson( "{$rename:{c:'b'},$set:{z:1}}" ) );
+ }
+ using ReplTests::Base::check;
+ void check() const {
+ ASSERT_EQUALS( 1, count() );
+ check( BSON( "_id" << 0 << "a" << 3 << "z" << 1 ) , one( fromjson( "{'_id':0}" ) ) );
+ }
+ void reset() const {
+ deleteAll( ns() );
+ insert( fromjson( "{'_id':0,a:3}" ) );
+ }
+ };
+
+
} // namespace Idempotence
class DeleteOpIsIdBased : public Base {
@@ -1140,6 +1189,9 @@ namespace ReplTests {
add< Idempotence::Pop >();
add< Idempotence::PopReverse >();
add< Idempotence::BitOp >();
+ add< Idempotence::Rename >();
+ add< Idempotence::RenameOverwrite >();
+ add< Idempotence::NoRename >();
add< DeleteOpIsIdBased >();
add< DbIdsTest >();
add< MemIdsTest >();