From 97ce60f8a4843eb660457747237e5ad768dc0dd0 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Fri, 10 Oct 2014 11:42:01 -0700 Subject: [PATCH] commands: Added global options list to command tests --- commands/command_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/commands/command_test.go b/commands/command_test.go index d0ce34147..bb4fc3a49 100644 --- a/commands/command_test.go +++ b/commands/command_test.go @@ -57,6 +57,13 @@ func TestOptionValidation(t *testing.T) { if err != nil { t.Error("Should have passed") } + + req = NewRequest() + req.options["enc"] = "json" + _, err = cmd.Call(nil, req) + if err != nil { + t.Error("Should have passed") + } } func TestRegistration(t *testing.T) { @@ -96,6 +103,15 @@ func TestRegistration(t *testing.T) { return nil, nil }, }, + + &Command{ + Options: []Option{ + Option{ []string{ "enc" }, String }, + }, + f: func(req *Request) (interface{}, error) { + return nil, nil + }, + }, } err := cmds[0].Register("foo", cmds[1]) @@ -112,4 +128,9 @@ func TestRegistration(t *testing.T) { if err == nil { t.Error("Should have failed (subcommand name collision)") } + + err = cmds[0].Register("baz", cmds[4]) + if err == nil { + t.Error("Should have failed (option name collision with global options)") + } }