mirror of https://github.com/velour/catbase.git
commit
baf1912e45
|
@ -38,6 +38,7 @@ func (mb *MockBot) EventReceived(msg msg.Message) {}
|
||||||
func (mb *MockBot) Filter(msg msg.Message, s string) string { return "" }
|
func (mb *MockBot) Filter(msg msg.Message, s string) string { return "" }
|
||||||
func (mb *MockBot) LastMessage(ch string) (msg.Message, error) { return msg.Message{}, nil }
|
func (mb *MockBot) LastMessage(ch string) (msg.Message, error) { return msg.Message{}, nil }
|
||||||
func (mb *MockBot) CheckAdmin(nick string) bool { return false }
|
func (mb *MockBot) CheckAdmin(nick string) bool { return false }
|
||||||
|
func (mb *MockBot) React(string, string, msg.Message) {}
|
||||||
|
|
||||||
func NewMockBot() *MockBot {
|
func NewMockBot() *MockBot {
|
||||||
db, err := sqlx.Open("sqlite3_custom", ":memory:")
|
db, err := sqlx.Open("sqlite3_custom", ":memory:")
|
||||||
|
|
|
@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
|
if tea, _ := regexp.MatchString("(?i)^tea\\. [^.]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
|
||||||
item, err := GetItem(p.DB, nick, ":tea:")
|
item, err := GetItem(p.DB, nick, ":tea:")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
||||||
|
|
|
@ -69,6 +69,15 @@ func TestTeaSkieselQuote(t *testing.T) {
|
||||||
assert.Nil(t, err)
|
assert.Nil(t, err)
|
||||||
assert.Equal(t, 0, item.Count)
|
assert.Equal(t, 0, item.Count)
|
||||||
}
|
}
|
||||||
|
func TestTeaUnicodeJapanese(t *testing.T) {
|
||||||
|
mb := bot.NewMockBot()
|
||||||
|
c := New(mb)
|
||||||
|
assert.NotNil(t, c)
|
||||||
|
c.Message(makeMessage("Tea. おちや. Hot."))
|
||||||
|
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||||
|
assert.Nil(t, err)
|
||||||
|
assert.Equal(t, 1, item.Count)
|
||||||
|
}
|
||||||
|
|
||||||
func TestResetMe(t *testing.T) {
|
func TestResetMe(t *testing.T) {
|
||||||
mb := bot.NewMockBot()
|
mb := bot.NewMockBot()
|
||||||
|
|
Loading…
Reference in New Issue