summaryrefslogtreecommitdiff
path: root/dbtests/querytests.cpp
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-03-23 18:32:05 -0400
committerAaron <aaron@10gen.com>2009-03-23 18:32:05 -0400
commit7e86cd69f3bcf7ba262880090e5aa843285c9ff6 (patch)
tree29b8a76080d6633b242942fffe1fa937eb895fc4 /dbtests/querytests.cpp
parent6b9abc614427f682ee0cf9eacb070b50085784ed (diff)
downloadmongo-7e86cd69f3bcf7ba262880090e5aa843285c9ff6.tar.gz
Move update related tests to separate file
Diffstat (limited to 'dbtests/querytests.cpp')
-rw-r--r--dbtests/querytests.cpp160
1 files changed, 1 insertions, 159 deletions
diff --git a/dbtests/querytests.cpp b/dbtests/querytests.cpp
index 05cda221912..3b3528623f9 100644
--- a/dbtests/querytests.cpp
+++ b/dbtests/querytests.cpp
@@ -1,4 +1,4 @@
-// pdfiletests.cpp : query.{h,cpp} unit tests.
+// querytests.cpp : query.{h,cpp} unit tests.
//
/**
@@ -150,66 +150,6 @@ namespace QueryTests {
};
DBDirectClient ClientBase::client_;
- class Fail : public ClientBase {
- public:
- virtual ~Fail() {}
- void run() {
- prep();
- ASSERT( !error() );
- doIt();
- ASSERT( error() );
- }
- protected:
- const char *ns() { return "QueryTests_Fail"; }
- virtual void prep() {
- insert( ns(), fromjson( "{a:1}" ) );
- }
- virtual void doIt() = 0;
- };
-
- class ModId : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{$set:{'_id':4}}" ) );
- }
- };
-
- class ModNonmodMix : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{$set:{a:4},z:3}" ) );
- }
- };
-
- class InvalidMod : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{$awk:{a:4}}" ) );
- }
- };
-
- class ModNotFirst : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{z:3,$set:{a:4}}" ) );
- }
- };
-
- class ModDuplicateFieldSpec : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{$set:{a:4},$inc:{a:1}}" ) );
- }
- };
-
- class IncNonNumber : public Fail {
- void doIt() {
- update( ns(), BSONObj(), fromjson( "{$inc:{a:'d'}}" ) );
- }
- };
-
- class IncTargetNonNumber : public Fail {
- void doIt() {
- insert( ns(), BSON( "a" << "a" ) );
- update( ns(), BSON( "a" << "a" ), fromjson( "{$inc:{a:1}}" ) );
- }
- };
-
class BoundedKey : public ClientBase {
public:
void run() {
@@ -358,89 +298,6 @@ namespace QueryTests {
}
};
- class SetBase : public ClientBase {
- public:
- ~SetBase() {
- client().dropCollection( ns() );
- }
- protected:
- const char *ns() { return "querytests.SetBase"; }
- };
-
- class SetNum : public SetBase {
- public:
- void run() {
- client().insert( ns(), BSON( "a" << 1 ) );
- client().update( ns(), BSON( "a" << 1 ), BSON( "$set" << BSON( "a" << 4 ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a" << 4 ) ).isEmpty() );
- }
- };
-
- class SetString : public SetBase {
- public:
- void run() {
- client().insert( ns(), BSON( "a" << "b" ) );
- client().update( ns(), BSON( "a" << "b" ), BSON( "$set" << BSON( "a" << "c" ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a" << "c" ) ).isEmpty() );
- }
- };
-
- class SetStringDifferentLength : public SetBase {
- public:
- void run() {
- client().insert( ns(), BSON( "a" << "b" ) );
- client().update( ns(), BSON( "a" << "b" ), BSON( "$set" << BSON( "a" << "cd" ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a" << "cd" ) ).isEmpty() );
- }
- };
-
- class SetStringToNum : public SetBase {
- public:
- void run() {
- client().insert( ns(), BSON( "a" << "b" ) );
- client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a" << 5 ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a" << 5 ) ).isEmpty() );
- }
- };
-
- class SetStringToNumInPlace : public SetBase {
- public:
- void run() {
- client().insert( ns(), BSON( "a" << "bcd" ) );
- client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a" << 5.0 ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a" << 5.0 ) ).isEmpty() );
- }
- };
-
- class ModDotted : public SetBase {
- public:
- void run() {
- client().insert( ns(), fromjson( "{a:{b:4}}" ) );
- client().update( ns(), BSONObj(), BSON( "$inc" << BSON( "a.b" << 10 ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a.b" << 14 ) ).isEmpty() );
- client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << 55 ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a.b" << 55 ) ).isEmpty() );
- }
- };
-
- class SetInPlaceDotted : public SetBase {
- public:
- void run() {
- client().insert( ns(), fromjson( "{a:{b:'cdef'}}" ) );
- client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << "llll" ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a.b" << "llll" ) ).isEmpty() );
- }
- };
-
- class SetRecreateDotted : public SetBase {
- public:
- void run() {
- client().insert( ns(), fromjson( "{a:{b:'cdef'}}" ) );
- client().update( ns(), BSONObj(), BSON( "$set" << BSON( "a.b" << "lllll" ) ) );
- ASSERT( !client().findOne( ns(), BSON( "a.b" << "lllll" ) ).isEmpty() );
- }
- };
-
class All : public UnitTest::Suite {
public:
All() {
@@ -449,13 +306,6 @@ namespace QueryTests {
add< CountFields >();
add< CountQueryFields >();
add< CountIndexedRegex >();
- add< ModId >();
- add< ModNonmodMix >();
- add< InvalidMod >();
- add< ModNotFirst >();
- add< ModDuplicateFieldSpec >();
- add< IncNonNumber >();
- add< IncTargetNonNumber >();
add< BoundedKey >();
add< GetMore >();
add< ReturnOneOfManyAndTail >();
@@ -464,14 +314,6 @@ namespace QueryTests {
add< TailableDelete >();
add< TailableInsertDelete >();
add< OplogReplayMode >();
- add< SetNum >();
- add< SetString >();
- add< SetStringDifferentLength >();
- add< SetStringToNum >();
- add< SetStringToNumInPlace >();
- add< ModDotted >();
- add< SetInPlaceDotted >();
- add< SetRecreateDotted >();
}
};