summaryrefslogtreecommitdiffstats
path: root/goctl_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'goctl_test.go')
-rw-r--r--goctl_test.go19
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++ {