mirror of https://github.com/velour/catbase.git
Merge pull request #41 from velour/tea-bug
Fixed error in Tea. Earl Grey. Hot. regex, updated tests.
This commit is contained in:
commit
b0210fd240
|
@ -136,7 +136,7 @@ func (p *CounterPlugin) Message(message msg.Message) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. (hot)|(iced)\\.?$", message.Body); tea {
|
||||
if tea, _ := regexp.MatchString("(?i)^tea\\. [0-9A-Za-z_ ]*\\. ((hot)|(iced))\\.?$", message.Body); tea {
|
||||
item, err := GetItem(p.DB, nick, ":tea:")
|
||||
if err != nil {
|
||||
log.Printf("Error finding item %s.%s: %s.", nick, ":tea:", err)
|
||||
|
|
|
@ -32,7 +32,7 @@ func TestTeaEarlGreyHot(t *testing.T) {
|
|||
assert.NotNil(t, c)
|
||||
c.Message(makeMessage("Tea. Earl Grey. Hot."))
|
||||
c.Message(makeMessage("Tea. Earl Grey. Hot."))
|
||||
item, err := GetItem(mb.DB(), "tester", "🍵")
|
||||
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 2, item.Count)
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func TestTeaGreenHot(t *testing.T) {
|
|||
c.Message(makeMessage("Tea. Green. Hot."))
|
||||
c.Message(makeMessage("Tea. Green. Hot"))
|
||||
c.Message(makeMessage("Tea. Green. Iced."))
|
||||
item, err := GetItem(mb.DB(), "tester", "🍵")
|
||||
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, item.Count)
|
||||
}
|
||||
|
@ -55,7 +55,17 @@ func TestTeaUnrelated(t *testing.T) {
|
|||
assert.NotNil(t, c)
|
||||
c.Message(makeMessage("Tea."))
|
||||
c.Message(makeMessage("Tea. It's great."))
|
||||
item, err := GetItem(mb.DB(), "tester", "🍵")
|
||||
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, item.Count)
|
||||
}
|
||||
|
||||
func TestTeaSkieselQuote(t *testing.T) {
|
||||
mb := bot.NewMockBot()
|
||||
c := New(mb)
|
||||
assert.NotNil(t, c)
|
||||
c.Message(makeMessage("blah, this is a whole page of explanation where \"we did local search and used a tabu list\" would have sufficed"))
|
||||
item, err := GetItem(mb.DB(), "tester", ":tea:")
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 0, item.Count)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue