diff options
author | Brian Cully <bjc@kublai.com> | 2015-07-10 18:00:24 +0000 |
---|---|---|
committer | Brian Cully <bjc@kublai.com> | 2015-07-10 18:07:57 +0000 |
commit | 9408742ed1a7eef568e2bf0d8e1aba390ae4d80b (patch) | |
tree | 380f45d9a542b1d492911457aedb1c6b632127cb /goctl_test.go | |
parent | ab72c2f0b56ce9929b46af1df09d30e2a7552b30 (diff) | |
download | goctl-9408742ed1a7eef568e2bf0d8e1aba390ae4d80b.tar.gz goctl-9408742ed1a7eef568e2bf0d8e1aba390ae4d80b.zip |
Move builtin commands into objects handlers on creation.
This simplifies lookup. Still prevents overriding of command handlers.
Diffstat (limited to 'goctl_test.go')
-rw-r--r-- | goctl_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/goctl_test.go b/goctl_test.go index d33fe32..a1e4711 100644 --- a/goctl_test.go +++ b/goctl_test.go @@ -154,6 +154,25 @@ func TestAddHandlers(t *testing.T) { } } +func TestCannotOverrideExtantHandlers(t *testing.T) { + gc := start(t) + defer gc.Stop() + + err := gc.AddHandler("ping", func(args []string) string { + return "gnip" + }) + if err != HandlerExists { + t.Error("Was able to override built-in ping handler.") + } + err = gc.AddHandlers([]*Handler{ + {"foo", func(args []string) string { return "foo" }}, + {"foo", func(args []string) string { return "foo" }}, + }) + if err != HandlerExists { + t.Error("Was able to assign two handlers for 'foo'.") + } +} + func BenchmarkStartStop(b *testing.B) { gc := NewGoctl(sockpath) for i := 0; i < b.N; i++ { |