2014-11-30 16:19:53 +08:00
|
|
|
package gobot
|
|
|
|
|
2016-02-22 13:21:24 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-10-20 16:27:09 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-02-22 13:21:24 +08:00
|
|
|
)
|
2014-11-30 16:19:53 +08:00
|
|
|
|
2023-10-20 16:27:09 +08:00
|
|
|
func TestCommander(t *testing.T) {
|
|
|
|
// arrange
|
2014-11-30 16:19:53 +08:00
|
|
|
c := NewCommander()
|
|
|
|
c.AddCommand("test", func(map[string]interface{}) interface{} {
|
|
|
|
return "hi"
|
|
|
|
})
|
|
|
|
|
2023-10-20 16:27:09 +08:00
|
|
|
// act && assert
|
2023-11-12 21:17:02 +08:00
|
|
|
assert.Len(t, c.Commands(), 1)
|
2023-10-20 16:27:09 +08:00
|
|
|
assert.NotNil(t, c.Command("test"))
|
|
|
|
assert.Nil(t, c.Command("booyeah"))
|
2014-11-30 16:19:53 +08:00
|
|
|
}
|