diff options
author | David Storch <david.storch@10gen.com> | 2018-11-28 17:25:24 -0500 |
---|---|---|
committer | David Storch <david.storch@10gen.com> | 2019-01-15 17:54:33 -0500 |
commit | de2a803ca492261cac1d7f43a9f7c847cd0ea24d (patch) | |
tree | 03cb6ea2b304463e7458f557246a95978d1ef96a /src/mongo/db/namespace_string_test.cpp | |
parent | af8fa6034f8a989cb47ee890c6a6b3e87e1bcf7b (diff) | |
download | mongo-de2a803ca492261cac1d7f43a9f7c847cd0ea24d.tar.gz |
SERVER-37451 Move all ClientCursor ownership to the global CursorManager.
Deleting the per-collection CursorManagers, and other
related cleanup, is left as future work.
Diffstat (limited to 'src/mongo/db/namespace_string_test.cpp')
-rw-r--r-- | src/mongo/db/namespace_string_test.cpp | 79 |
1 files changed, 14 insertions, 65 deletions
diff --git a/src/mongo/db/namespace_string_test.cpp b/src/mongo/db/namespace_string_test.cpp index 87456009bf3..44976b5e8ee 100644 --- a/src/mongo/db/namespace_string_test.cpp +++ b/src/mongo/db/namespace_string_test.cpp @@ -152,62 +152,20 @@ TEST(NamespaceStringTest, ListCollectionsCursorNS) { ASSERT(!NamespaceString("test.$cmd.listIndexes.foo").isListCollectionsCursorNS()); } -TEST(NamespaceStringTest, ListIndexesCursorNS) { - NamespaceString ns1("test.$cmd.listIndexes.f"); - ASSERT(ns1.isListIndexesCursorNS()); - ASSERT("test.f" == ns1.getTargetNSForListIndexes().ns()); - - NamespaceString ns2("test.$cmd.listIndexes.foo"); - ASSERT(ns2.isListIndexesCursorNS()); - ASSERT("test.foo" == ns2.getTargetNSForListIndexes().ns()); - - NamespaceString ns3("test.$cmd.listIndexes.foo.bar"); - ASSERT(ns3.isListIndexesCursorNS()); - ASSERT("test.foo.bar" == ns3.getTargetNSForListIndexes().ns()); - - ASSERT(!NamespaceString("test.foo").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.foo.$cmd.listIndexes").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.foo.").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.listIndexes").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.listIndexes.").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.listCollections").isListIndexesCursorNS()); - ASSERT(!NamespaceString("test.$cmd.listCollections.foo").isListIndexesCursorNS()); -} - -TEST(NamespaceStringTest, IsGloballyManagedNamespace) { - ASSERT_TRUE(NamespaceString{"test.$cmd.aggregate.foo"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.listIndexes.foo"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.otherCommand.foo"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.listCollections"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.otherCommand"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.aggregate"}.isGloballyManagedNamespace()); - ASSERT_TRUE(NamespaceString{"test.$cmd.listIndexes"}.isGloballyManagedNamespace()); - - ASSERT_FALSE(NamespaceString{"test.foo"}.isGloballyManagedNamespace()); - ASSERT_FALSE(NamespaceString{"test.$cmd"}.isGloballyManagedNamespace()); - - ASSERT_FALSE(NamespaceString{"$cmd.aggregate.foo"}.isGloballyManagedNamespace()); - ASSERT_FALSE(NamespaceString{"$cmd.listCollections"}.isGloballyManagedNamespace()); -} - -TEST(NamespaceStringTest, GetTargetNSForGloballyManagedNamespace) { - ASSERT_EQ( - (NamespaceString{"test", "foo"}), - NamespaceString{"test.$cmd.aggregate.foo"}.getTargetNSForGloballyManagedNamespace().get()); - ASSERT_EQ((NamespaceString{"test", "foo"}), - NamespaceString{"test.$cmd.listIndexes.foo"} - .getTargetNSForGloballyManagedNamespace() - .get()); - ASSERT_EQ((NamespaceString{"test", "foo"}), - NamespaceString{"test.$cmd.otherCommand.foo"} - .getTargetNSForGloballyManagedNamespace() - .get()); - - ASSERT_FALSE( - NamespaceString{"test.$cmd.listCollections"}.getTargetNSForGloballyManagedNamespace()); - ASSERT_FALSE( - NamespaceString{"test.$cmd.otherCommand"}.getTargetNSForGloballyManagedNamespace()); +TEST(NamespaceStringTest, IsCollectionlessCursorNamespace) { + ASSERT_TRUE(NamespaceString{"test.$cmd.aggregate.foo"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.listIndexes.foo"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.otherCommand.foo"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.listCollections"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.otherCommand"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.aggregate"}.isCollectionlessCursorNamespace()); + ASSERT_TRUE(NamespaceString{"test.$cmd.listIndexes"}.isCollectionlessCursorNamespace()); + + ASSERT_FALSE(NamespaceString{"test.foo"}.isCollectionlessCursorNamespace()); + ASSERT_FALSE(NamespaceString{"test.$cmd"}.isCollectionlessCursorNamespace()); + + ASSERT_FALSE(NamespaceString{"$cmd.aggregate.foo"}.isCollectionlessCursorNamespace()); + ASSERT_FALSE(NamespaceString{"$cmd.listCollections"}.isCollectionlessCursorNamespace()); } TEST(NamespaceStringTest, IsDropPendingNamespace) { @@ -355,15 +313,6 @@ TEST(NamespaceStringTest, makeListCollectionsNSIsCorrect) { ASSERT(ns.isListCollectionsCursorNS()); } -TEST(NamespaceStringTest, makeListIndexesNSIsCorrect) { - NamespaceString ns = NamespaceString::makeListIndexesNSS("DB", "COLL"); - ASSERT_EQUALS("DB", ns.db()); - ASSERT_EQUALS("$cmd.listIndexes.COLL", ns.coll()); - ASSERT(ns.isValid()); - ASSERT(ns.isListIndexesCursorNS()); - ASSERT_EQUALS(NamespaceString("DB.COLL"), ns.getTargetNSForListIndexes()); -} - TEST(NamespaceStringTest, EmptyNSStringReturnsEmptyColl) { NamespaceString nss{}; ASSERT_TRUE(nss.isEmpty()); |