summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands/list_collections_filter_test.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james.wahlin@10gen.com>2016-08-30 16:57:35 -0400
committerJames Wahlin <james.wahlin@10gen.com>2016-08-31 19:00:59 -0400
commitbbc9748b355ae0ac07d6ac37db757712bc35af43 (patch)
tree770c7d6f0c71d2c515e4f0a1c2e7ca371776c803 /src/mongo/db/commands/list_collections_filter_test.cpp
parentf5c9d27ca6f0f4e1e2673c64b84b628ac29493ec (diff)
downloadmongo-bbc9748b355ae0ac07d6ac37db757712bc35af43.tar.gz
SERVER-25796 copydb support for views + additional cloner tests
Diffstat (limited to 'src/mongo/db/commands/list_collections_filter_test.cpp')
-rw-r--r--src/mongo/db/commands/list_collections_filter_test.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/mongo/db/commands/list_collections_filter_test.cpp b/src/mongo/db/commands/list_collections_filter_test.cpp
new file mode 100644
index 00000000000..f72e866b6b5
--- /dev/null
+++ b/src/mongo/db/commands/list_collections_filter_test.cpp
@@ -0,0 +1,71 @@
+/**
+ * Copyright (C) 2016 MongoDB Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the GNU Affero General Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/commands/list_collections_filter.h"
+
+#include "mongo/bson/json.h"
+#include "mongo/unittest/unittest.h"
+
+namespace {
+
+using namespace mongo;
+
+TEST(ListCollectionsFilterTest, AddCollectionFilter) {
+ BSONObj filter = fromjson("{'options.capped': false}");
+ BSONObj expected = fromjson(
+ "{$and: ["
+ "{'options.capped': false}, "
+ "{$or: [{type: 'collection'}, {type: {$exists: false}}]}]}");
+
+ ASSERT_BSONOBJ_EQ(expected, ListCollectionsFilter::addTypeCollectionFilter(filter));
+}
+
+TEST(ListCollectionsFilterTest, AddCollectionFilterToEmptyInputFilter) {
+ BSONObj filter;
+ BSONObj expected = fromjson("{$or: [{type: 'collection'}, {type: {$exists: false}}]}");
+
+ ASSERT_BSONOBJ_EQ(expected, ListCollectionsFilter::addTypeCollectionFilter(filter));
+}
+
+TEST(ListCollectionsFilterTest, AddViewFilter) {
+ BSONObj filter = fromjson("{'options.capped': false}");
+ BSONObj expected = fromjson("{$and: [{'options.capped': false}, {type: 'view'}]}");
+
+ ASSERT_BSONOBJ_EQ(expected, ListCollectionsFilter::addTypeViewFilter(filter));
+}
+
+TEST(ListCollectionsFilterTest, AddViewFilterToEmptyInputFilter) {
+ BSONObj filter;
+ BSONObj expected = fromjson("{type: 'view'}");
+
+ ASSERT_BSONOBJ_EQ(expected, ListCollectionsFilter::addTypeViewFilter(filter));
+}
+
+} // namespace