diff options
author | Thomas Schubert <thomas.schubert@mongodb.com> | 2017-07-31 23:03:23 -0400 |
---|---|---|
committer | Thomas Schubert <thomas.schubert@mongodb.com> | 2017-07-31 23:03:23 -0400 |
commit | cf38c1b8a0a8dca4a11737581beafef4fe120bcd (patch) | |
tree | 548b58b5bbf6672b7423cf30f646c40cfea4f240 /src/mongo/gotools/common/db/namespaces_test.go | |
parent | 4463700eb94a5ee95c706d69cbb7bf44e67a50d2 (diff) | |
download | mongo-cf38c1b8a0a8dca4a11737581beafef4fe120bcd.tar.gz |
Import tools: 4f093ae71cdb4c6a6e9de7cd1dc67ea4405f0013 from branch v3.4r3.4.7-rc0r3.4.7
ref: 29b8883c56..4f093ae71c
for: 3.4.7
TOOLS-1109 failes to build on arm64 (syscall.Dup2 not supported)
TOOLS-1542 dump and export shouldn't count views before running
TOOLS-1563 windows tests are failing after `use mongodb 3.4 "current" tests`
TOOLS-1577 update the readme with information about mongoreplay
TOOLS-1713 Move mongoreplay evergreen config .evergreen.yml into common.yml
TOOLS-1741 mongoimport --uri throws errors when passed Atlas Connection String URI
TOOLS-1743 legacy24 and legacy26 dumprestore tests failing on master
Diffstat (limited to 'src/mongo/gotools/common/db/namespaces_test.go')
-rw-r--r-- | src/mongo/gotools/common/db/namespaces_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mongo/gotools/common/db/namespaces_test.go b/src/mongo/gotools/common/db/namespaces_test.go new file mode 100644 index 00000000000..0e390a2f43c --- /dev/null +++ b/src/mongo/gotools/common/db/namespaces_test.go @@ -0,0 +1,52 @@ +package db + +import ( + "fmt" + "testing" + + . "github.com/smartystreets/goconvey/convey" +) + +type stripDBFromNamespaceTestCase struct { + inputNamespace string + inputDBName string + + outputNamespace string + outputError error +} + +func TestStripDBFromNamespace(t *testing.T) { + Convey("When testing StripDBFromNamespace with cases", t, func() { + testCases := []stripDBFromNamespaceTestCase{ + { + inputNamespace: "database.col", + inputDBName: "database", + + outputNamespace: "col", + outputError: nil, + }, + { + inputNamespace: "database2.col", + inputDBName: "database", + + outputNamespace: "", + outputError: fmt.Errorf("namespace 'database2.col' format is invalid - expected to start with 'database.'"), + }, + { + inputNamespace: "database.col", + inputDBName: "notAPrefix", + + outputNamespace: "", + outputError: fmt.Errorf("namespace 'database.col' format is invalid - expected to start with 'notAPrefix.'"), + }, + } + Convey("cases should match expected", func() { + for _, tc := range testCases { + resultNamespace, resultError := StripDBFromNamespace(tc.inputNamespace, tc.inputDBName) + So(resultError, ShouldResemble, tc.outputError) + So(resultNamespace, ShouldEqual, tc.outputNamespace) + } + }) + }) + +} |