summaryrefslogtreecommitdiff
path: root/src/mongo/dbtests
diff options
context:
space:
mode:
authorXin Hao Zhang <xinhao.zhang@mongodb.com>2019-06-03 17:54:21 -0400
committerXin Hao Zhang <xinhao.zhang@mongodb.com>2019-06-05 14:10:20 -0400
commitd5d674930f1c67f6c87d73715f82f608668d72fa (patch)
treefa68f6c6bc6252bfdce7123b945078f10af96bff /src/mongo/dbtests
parentd8e2c4748fda6fc24ea0d1bb1541ea9c66f5e1cf (diff)
downloadmongo-d5d674930f1c67f6c87d73715f82f608668d72fa.tar.gz
SERVER-41263 Disallow empty string in index key type
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r--src/mongo/dbtests/commandtests.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/dbtests/commandtests.cpp b/src/mongo/dbtests/commandtests.cpp
index a5c7ce5fbf5..8be8065bf54 100644
--- a/src/mongo/dbtests/commandtests.cpp
+++ b/src/mongo/dbtests/commandtests.cpp
@@ -242,6 +242,31 @@ public:
}
};
+
+class CreateIndexWithEmptyStringAsValue : Base {
+public:
+ void run() {
+ ASSERT(db.createCollection(nss().ns()));
+
+ BSONObjBuilder indexSpec;
+ indexSpec.append("key",
+ BSON("a"
+ << ""));
+
+ BSONArrayBuilder indexes;
+ indexes.append(indexSpec.obj());
+
+ BSONObjBuilder cmd;
+ cmd.append("createIndexes", nsColl());
+ cmd.append("indexes", indexes.arr());
+
+ BSONObj result;
+ bool ok = db.runCommand(nsDb(), cmd.obj(), result);
+ log() << result.jsonString();
+ ASSERT(!ok);
+ }
+};
+
class FindAndModify : Base {
public:
void run() {
@@ -372,6 +397,7 @@ public:
add<SymbolArgument::GeoSearch>();
add<SymbolArgument::CreateIndexWithNoKey>();
add<SymbolArgument::CreateIndexWithDuplicateKey>();
+ add<SymbolArgument::CreateIndexWithEmptyStringAsValue>();
add<RolesInfoShouldNotReturnDuplicateFieldNames>();
}
};