func (c *Core) handleMentionCatchAll(b core.Bot, m *slack.Message) error { message := util.TrimWhitespace(core.LessMentions(m.Text)) if core.IsSalutation(message) { return c.handleSalutation(b, m) } return c.handleUnknown(b, m) }
func TestHandleMentionCatchAllSalutation(t *testing.T) { assert := assert.New(t) c := &Core{} mb := core.NewMockBot(slack.UUIDv4().ToShortString()) gotMessage := "" mb.MockMessageHandler(func(b core.Bot, m *slack.Message) error { gotMessage = m.Text return nil }) message := "hey <@BOT>" assert.True(core.IsSalutation(message)) err := c.handleSalutation(mb, core.MockMessage(message)) assert.Nil(err) assert.False(strings.Contains(gotMessage, "how to respond")) }