summaryrefslogtreecommitdiff
path: root/src/mongo/db/namespace_string.h
diff options
context:
space:
mode:
authorjannaerin <golden.janna@gmail.com>2023-02-01 20:54:39 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2023-02-08 02:46:14 +0000
commit567bcd0e4822d726aea15f0338c89c49de2a56b5 (patch)
treefa2a6ea1d3cbd4872fba26df3fdb44548544206f /src/mongo/db/namespace_string.h
parentf7afadd90f50662b2b3b3a45595b65b37a59bdc3 (diff)
downloadmongo-567bcd0e4822d726aea15f0338c89c49de2a56b5.tar.gz
SERVER-73112 Expose function to construct NamespaceString in unit tests
Diffstat (limited to 'src/mongo/db/namespace_string.h')
-rw-r--r--src/mongo/db/namespace_string.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mongo/db/namespace_string.h b/src/mongo/db/namespace_string.h
index fc451951373..cbab3d2c23c 100644
--- a/src/mongo/db/namespace_string.h
+++ b/src/mongo/db/namespace_string.h
@@ -371,6 +371,39 @@ public:
static NamespaceString parseFromStringExpectTenantIdInMultitenancyMode(StringData ns);
/**
+ * These functions construct a NamespaceString without checking for presence of TenantId.
+ *
+ * MUST only be used for tests.
+ */
+ static NamespaceString createNamespaceString_forTest(StringData ns) {
+ return NamespaceString(boost::none, ns);
+ }
+
+ static NamespaceString createNamespaceString_forTest(const DatabaseName& dbName) {
+ return NamespaceString(dbName);
+ }
+
+ static NamespaceString createNamespaceString_forTest(StringData db, StringData coll) {
+ return NamespaceString(boost::none, db, coll);
+ }
+
+ static NamespaceString createNamespaceString_forTest(const DatabaseName& dbName,
+ StringData coll) {
+ return NamespaceString(dbName, coll);
+ }
+
+ static NamespaceString createNamespaceString_forTest(const boost::optional<TenantId>& tenantId,
+ StringData ns) {
+ return NamespaceString(tenantId, ns);
+ }
+
+ static NamespaceString createNamespaceString_forTest(const boost::optional<TenantId>& tenantId,
+ StringData db,
+ StringData coll) {
+ return NamespaceString(tenantId, db, coll);
+ }
+
+ /**
* Constructs the namespace '<dbName>.$cmd.aggregate', which we use as the namespace for
* aggregation commands with the format {aggregate: 1}.
*/