mirror of https://github.com/velour/catbase.git
63 lines
1.3 KiB
Go
63 lines
1.3 KiB
Go
// © 2013 the CatBase Authors under the WTFPL. See AUTHORS for the list of authors.
|
|
|
|
package nerdepedia
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/velour/catbase/bot"
|
|
"github.com/velour/catbase/bot/msg"
|
|
"github.com/velour/catbase/bot/user"
|
|
)
|
|
|
|
func makeMessage(payload string) msg.Message {
|
|
isCmd := strings.HasPrefix(payload, "!")
|
|
if isCmd {
|
|
payload = payload[1:]
|
|
}
|
|
return msg.Message{
|
|
User: &user.User{Name: "tester"},
|
|
Channel: "test",
|
|
Body: payload,
|
|
Command: isCmd,
|
|
}
|
|
}
|
|
|
|
func TestWars(t *testing.T) {
|
|
mb := bot.NewMockBot()
|
|
c := New(mb)
|
|
assert.NotNil(t, c)
|
|
res := c.Message(makeMessage("help me obi-wan"))
|
|
assert.Len(t, mb.Messages, 1)
|
|
assert.True(t, res)
|
|
}
|
|
|
|
func TestTrek(t *testing.T) {
|
|
mb := bot.NewMockBot()
|
|
c := New(mb)
|
|
assert.NotNil(t, c)
|
|
res := c.Message(makeMessage("live long and prosper"))
|
|
assert.Len(t, mb.Messages, 1)
|
|
assert.True(t, res)
|
|
}
|
|
|
|
func TestDune(t *testing.T) {
|
|
mb := bot.NewMockBot()
|
|
c := New(mb)
|
|
assert.NotNil(t, c)
|
|
res := c.Message(makeMessage("bless the maker"))
|
|
assert.Len(t, mb.Messages, 1)
|
|
assert.True(t, res)
|
|
}
|
|
|
|
func TestPoke(t *testing.T) {
|
|
mb := bot.NewMockBot()
|
|
c := New(mb)
|
|
assert.NotNil(t, c)
|
|
res := c.Message(makeMessage("gotta catch em all"))
|
|
assert.Len(t, mb.Messages, 1)
|
|
assert.True(t, res)
|
|
}
|