summaryrefslogtreecommitdiff
path: root/mongofiles
diff options
context:
space:
mode:
authorWisdom Omuya <deafgoat@gmail.com>2014-11-17 14:50:07 -0500
committerWisdom Omuya <deafgoat@gmail.com>2014-11-17 14:50:07 -0500
commit3cc40bf92d2e4de7cf60e4ee5c901feb61873d3a (patch)
tree8afe175a2760e0d7caff3436a339dd19fa47be31 /mongofiles
parent4220e1b71e04a89a397929f5e231aaabd3fa6073 (diff)
downloadmongo-3cc40bf92d2e4de7cf60e4ee5c901feb61873d3a.tar.gz
TOOLS-376: fixup mongofiles tests
Former-commit-id: 04a41a180d5c5bdfa4e96ddcf93e212677271e7b
Diffstat (limited to 'mongofiles')
-rw-r--r--mongofiles/mongofiles_test.go33
1 files changed, 12 insertions, 21 deletions
diff --git a/mongofiles/mongofiles_test.go b/mongofiles/mongofiles_test.go
index f6c072a7249..e9ffa0bc03a 100644
--- a/mongofiles/mongofiles_test.go
+++ b/mongofiles/mongofiles_test.go
@@ -162,51 +162,42 @@ func TestValidArguments(t *testing.T) {
testutil.VerifyTestType(t, testutil.UNIT_TEST_TYPE)
Convey("With a MongoFiles instance", t, func() {
-
+ args := []string{"search", "file"}
+ mf, err := simpleMongoFilesInstance(args)
+ So(err, ShouldBeNil)
Convey("It should error out when no arguments fed", func() {
args := []string{}
-
- _, err := ValidateCommand(args)
+ err := mf.ValidateCommand(args)
So(err, ShouldNotBeNil)
- So(err.Error(), ShouldEqual, "you must specify a command")
+ So(err.Error(), ShouldEqual, "no command specified")
})
Convey("It should error out when too many positional arguments provided", func() {
args := []string{"list", "something", "another"}
-
- _, err := ValidateCommand(args)
+ err := mf.ValidateCommand(args)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldEqual, "too many positional arguments")
})
Convey("It should not error out when list command isn't given an argument", func() {
args := []string{"list"}
-
- fileName, err := ValidateCommand(args)
- So(err, ShouldBeNil)
- So(fileName, ShouldEqual, "")
+ So(mf.ValidateCommand(args), ShouldBeNil)
+ So(mf.StorageOptions.LocalFileName, ShouldEqual, "")
})
Convey("It should error out when any of (get|put|delete|search) not given supporting argument", func() {
- var args []string
-
for _, command := range []string{"get", "put", "delete", "search"} {
- args = []string{command}
-
- _, err := ValidateCommand(args)
+ args := []string{command}
+ err := mf.ValidateCommand(args)
So(err, ShouldNotBeNil)
- So(err.Error(),
- ShouldEqual,
- fmt.Sprintf("'%v' requires a non-empty supporting argument",
- command),
- )
+ So(err.Error(), ShouldEqual, fmt.Sprintf("'%v' argument missing", command))
}
})
Convey("It should error out when a nonsensical command is given", func() {
args := []string{"commandnonexistent"}
- _, err := ValidateCommand(args)
+ err := mf.ValidateCommand(args)
So(err, ShouldNotBeNil)
So(err.Error(), ShouldEqual, fmt.Sprintf("'%v' is not a valid command", args[0]))
})