clear index cache in c++ client on dropping collection / database

This commit is contained in:
Aaron
2009-04-16 11:27:10 -04:00
parent c4cbebd356
commit ee6ef61ca4
2 changed files with 43 additions and 2 deletions

View File

@@ -389,6 +389,32 @@ namespace QueryTests {
ASSERT( client().findOne( ns, fromjson( "{'a.b':{$ne:1}}" ) ).isEmpty() );
}
};
class AutoResetIndexCache : public ClientBase {
public:
~AutoResetIndexCache() {
client().dropCollection( "querytests.AutoResetIndexCache" );
}
static const char *ns() { return "querytests.AutoResetIndexCache"; }
static const char *idxNs() { return "querytests.system.indexes"; }
void index() const { ASSERT( !client().findOne( idxNs(), BSONObj() ).isEmpty() ); }
void noIndex() const { ASSERT( client().findOne( idxNs(), BSONObj() ).isEmpty() ); }
void checkIndex() {
client().ensureIndex( ns(), BSON( "a" << 1 ) );
index();
}
void run() {
client().dropDatabase( "querytests" );
noIndex();
checkIndex();
client().dropCollection( ns() );
noIndex();
checkIndex();
client().dropDatabase( "querytests" );
noIndex();
checkIndex();
}
};
class All : public UnitTest::Suite {
public:
@@ -411,6 +437,7 @@ namespace QueryTests {
add< EmptyFieldSpec >();
add< MultiNe >();
add< EmbeddedNe >();
add< AutoResetIndexCache >();
}
};