2014-11-30 16:19:53 +08:00
|
|
|
package gobot
|
|
|
|
|
2016-02-22 13:21:24 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot/gobottest"
|
2016-02-22 13:21:24 +08:00
|
|
|
)
|
2014-11-30 16:19:53 +08:00
|
|
|
|
|
|
|
func TestCommaner(t *testing.T) {
|
|
|
|
c := NewCommander()
|
|
|
|
c.AddCommand("test", func(map[string]interface{}) interface{} {
|
|
|
|
return "hi"
|
|
|
|
})
|
|
|
|
|
|
|
|
if _, ok := c.Commands()["test"]; !ok {
|
|
|
|
t.Errorf("Could not add command to list of Commands")
|
|
|
|
}
|
|
|
|
|
|
|
|
command := c.Command("test")
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Refute(t, command, nil)
|
2014-11-30 16:19:53 +08:00
|
|
|
|
|
|
|
command = c.Command("booyeah")
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, command, (func(map[string]interface{}) interface{})(nil))
|
2014-11-30 16:19:53 +08:00
|
|
|
}
|