Esempio n. 1
0
func TestHelp(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	c.Help("channel", []string{})
	assert.Len(t, mb.Messages, 1)
}
Esempio n. 2
0
func makePlugin(t *testing.T) (*RememberPlugin, *Factoid, *bot.MockBot) {
	mb := bot.NewMockBot()
	f := New(mb) // for DB table
	p := NewRemember(mb)
	assert.NotNil(t, p)
	return p, f, mb
}
Esempio n. 3
0
func makePlugin(t *testing.T) (*LeftpadPlugin, *bot.MockBot) {
	mb := bot.NewMockBot()
	counter.New(mb)
	p := New(mb)
	assert.NotNil(t, p)
	return p, mb
}
Esempio n. 4
0
func makeBeersPlugin(t *testing.T) (*BeersPlugin, *bot.MockBot) {
	mb := bot.NewMockBot()
	counter.New(mb)
	b := New(mb)
	assert.NotNil(t, b)
	return b, mb
}
Esempio n. 5
0
func TestBabblerMerge(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Babbler.DefaultUsers = []string{"seabass"}
	assert.NotNil(t, c)

	seabass := makeMessage("<seabass> This is a message")
	seabass.User = &user.User{Name: "seabass"}
	res := c.Message(seabass)
	assert.Len(t, c.babblers, 1)
	assert.Len(t, mb.Messages, 0)

	seabass.Body = "<seabass> This is another message"
	res = c.Message(seabass)

	seabass.Body = "<seabass> This is a long message"
	res = c.Message(seabass)

	res = c.Message(makeMessage("!merge babbler seabass into seabass2"))
	assert.True(t, res)
	assert.Len(t, mb.Messages, 1)
	assert.Contains(t, mb.Messages[0], "mooooiggged")

	res = c.Message(makeMessage("!seabass2 says"))
	assert.True(t, res)
	assert.Len(t, mb.Messages, 2)

	assert.Contains(t, mb.Messages[1], "<seabass2> this is")
	assert.Contains(t, mb.Messages[1], "message")
}
Esempio n. 6
0
func TestSay(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("say hello"))
	assert.Len(t, mb.Messages, 0)
	assert.False(t, res)
}
Esempio n. 7
0
func TestBadSides(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!1daoeu"))
	assert.False(t, res)
	assert.Len(t, mb.Messages, 0)
}
Esempio n. 8
0
func TestNonJoinEvent(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Event("SPLURT", makeMessage("hello there"))
	assert.Len(t, mb.Messages, 0)
	assert.False(t, res)
}
Esempio n. 9
0
func TestCounterOne(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	c.Message(makeMessage("test++"))
	assert.Len(t, mb.Messages, 1)
	assert.Equal(t, mb.Messages[0], "tester has 1 test.")
}
Esempio n. 10
0
func TestNotCommand(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("1d6"))
	assert.False(t, res)
	assert.Len(t, mb.Messages, 0)
}
Esempio n. 11
0
func TestReminderParse(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!remind testuser in unparseable don't fail this test"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "Easy cowboy, not sure I can parse that duration.")
}
Esempio n. 12
0
func TestSayCommand(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!say hello"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "hello")
}
Esempio n. 13
0
func TestNoSayings(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.sayings = []string{}
	assert.NotNil(t, c)
	res := c.Event("JOIN", makeMessage("hello there"))
	assert.Len(t, mb.Messages, 0)
	assert.False(t, res)
}
Esempio n. 14
0
func TestLotsOfDice(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!100d100"))
	assert.True(t, res)
	assert.Len(t, mb.Messages, 1)
	assert.Contains(t, mb.Messages[0], "You're a dick.")
}
Esempio n. 15
0
func TestDice(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!5d6"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "tester, you rolled:")
}
Esempio n. 16
0
func TestNineChars(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.enforceNicks = true
	assert.NotNil(t, c)
	res := c.Message(makeMessage("hello there"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "OCD")
}
Esempio n. 17
0
func TestBabblerNoBabbler(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Babbler.DefaultUsers = []string{"seabass"}
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!seabass2 says"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "could not find babbler: seabass2")
}
Esempio n. 18
0
func TestCounterFour(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("test++"))
	}
	assert.Len(t, mb.Messages, 4)
	assert.Equal(t, mb.Messages[3], "tester has 4 test.")
}
Esempio n. 19
0
func TestBabblerNothingSaid(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Babbler.DefaultUsers = []string{"seabass"}
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!seabass says"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "Ze ain't said nothin")
}
Esempio n. 20
0
func TestWelcome(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.sayings = []string{"Hi"}
	assert.NotNil(t, c)
	res := c.Event("JOIN", makeMessage("hello there"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "Hi")
}
Esempio n. 21
0
func TestGoatseWithNickCommand(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!g****e seabass"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "g o a t s e")
	assert.Contains(t, mb.Messages[0], "seabass")
}
Esempio n. 22
0
func TestReminder(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	res := c.Message(makeMessage("!remind testuser in 1s don't fail this test"))
	time.Sleep(2 * time.Second)
	assert.Len(t, mb.Messages, 2)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "Sure tester, I'll remind testuser.")
	assert.Contains(t, mb.Messages[1], "Hey testuser, tester wanted you to be reminded: don't fail this test")
}
Esempio n. 23
0
func TestFriendCounterDecrement(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("other.test++"))
		assert.Equal(t, mb.Messages[i], fmt.Sprintf("other has %d test.", i+1))
	}
	c.Message(makeMessage("other.test--"))
	assert.Len(t, mb.Messages, 5)
	assert.Equal(t, mb.Messages[4], "other has 3 test.")
}
Esempio n. 24
0
func TestClear(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("test++"))
		assert.Equal(t, mb.Messages[i], fmt.Sprintf("tester has %d test.", i+1))
	}
	res := c.Message(makeMessage("!clear test"))
	assert.True(t, res)
	assert.Len(t, mb.Actions, 1)
	assert.Equal(t, mb.Actions[0], "chops a few test out of his brain")
}
Esempio n. 25
0
func makeTwitchPlugin(t *testing.T) (*TwitchPlugin, *bot.MockBot) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Twitch.Users = map[string][]string{"test": []string{"drseabass"}}
	assert.NotNil(t, c)

	c.twitchList["drseabass"] = &Twitcher{
		name: "drseabass",
		game: "",
	}

	return c, mb
}
Esempio n. 26
0
func TestCount(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("test++"))
		assert.Equal(t, mb.Messages[i], fmt.Sprintf("tester has %d test.", i+1))
	}
	res := c.Message(makeMessage("!count test"))
	assert.True(t, res)
	assert.Len(t, mb.Messages, 5)
	assert.Equal(t, mb.Messages[4], "tester has 4 test.")
}
Esempio n. 27
0
func TestBabblerBatch(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Babbler.DefaultUsers = []string{"seabass"}
	assert.NotNil(t, c)
	seabass := makeMessage("batch learn for seabass This is a message! This is another message. This is not a long message? This is not a message! This is not another message. This is a long message?")
	res := c.Message(seabass)
	assert.Len(t, c.babblers, 2)
	assert.Len(t, mb.Messages, 1)
	res = c.Message(makeMessage("!seabass says"))
	assert.Len(t, mb.Messages, 2)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[1], "this is")
	assert.Contains(t, mb.Messages[1], "message")
}
Esempio n. 28
0
func TestDecrementZero(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("test++"))
		assert.Equal(t, mb.Messages[i], fmt.Sprintf("tester has %d test.", i+1))
	}
	j := 4
	for i := 4; i > 0; i-- {
		c.Message(makeMessage("test--"))
		assert.Equal(t, mb.Messages[j], fmt.Sprintf("tester has %d test.", i-1))
		j++
	}
	assert.Len(t, mb.Messages, 8)
	assert.Equal(t, mb.Messages[7], "tester has 0 test.")
}
Esempio n. 29
0
func TestBabblerBadSeed(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	c.config.Babbler.DefaultUsers = []string{"seabass"}
	assert.NotNil(t, c)
	seabass := makeMessage("This is a message")
	seabass.User = &user.User{Name: "seabass"}
	res := c.Message(seabass)
	assert.Len(t, c.babblers, 1)
	seabass.Body = "This is another message"
	res = c.Message(seabass)
	seabass.Body = "This is a long message"
	res = c.Message(seabass)
	res = c.Message(makeMessage("!seabass says long message"))
	assert.Len(t, mb.Messages, 1)
	assert.True(t, res)
	assert.Contains(t, mb.Messages[0], "try seabass says [seed-token]")
}
Esempio n. 30
0
func TestInspectMe(t *testing.T) {
	mb := bot.NewMockBot()
	c := New(mb)
	assert.NotNil(t, c)
	for i := 0; i < 4; i++ {
		c.Message(makeMessage("test++"))
		assert.Equal(t, mb.Messages[i], fmt.Sprintf("tester has %d test.", i+1))
	}
	for i := 0; i < 2; i++ {
		c.Message(makeMessage("f***s++"))
		assert.Equal(t, mb.Messages[i+4], fmt.Sprintf("tester has %d f***s.", i+1))
	}
	for i := 0; i < 20; i++ {
		c.Message(makeMessage("cheese++"))
		assert.Equal(t, mb.Messages[i+6], fmt.Sprintf("tester has %d cheese.", i+1))
	}
	res := c.Message(makeMessage("!inspect me"))
	assert.True(t, res)
	assert.Len(t, mb.Messages, 27)
	assert.Equal(t, mb.Messages[26], "tester has the following counters: test: 4, f***s: 2, cheese: 20.")
}