當前位置: 首頁>>代碼示例>>Golang>>正文


Golang bot.NewMockBot函數代碼示例

本文整理匯總了Golang中github.com/velour/catbase/bot.NewMockBot函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewMockBot函數的具體用法?Golang NewMockBot怎麽用?Golang NewMockBot使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewMockBot函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestHelp

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:7,代碼來源:reminder_test.go

示例2: makePlugin

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
}
開發者ID:velour,項目名稱:catbase,代碼行數:7,代碼來源:remember_test.go

示例3: makePlugin

func makePlugin(t *testing.T) (*LeftpadPlugin, *bot.MockBot) {
	mb := bot.NewMockBot()
	counter.New(mb)
	p := New(mb)
	assert.NotNil(t, p)
	return p, mb
}
開發者ID:velour,項目名稱:catbase,代碼行數:7,代碼來源:leftpad_test.go

示例4: makeBeersPlugin

func makeBeersPlugin(t *testing.T) (*BeersPlugin, *bot.MockBot) {
	mb := bot.NewMockBot()
	counter.New(mb)
	b := New(mb)
	assert.NotNil(t, b)
	return b, mb
}
開發者ID:velour,項目名稱:catbase,代碼行數:7,代碼來源:beers_test.go

示例5: TestBabblerMerge

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")
}
開發者ID:velour,項目名稱:catbase,代碼行數:30,代碼來源:babbler_test.go

示例6: TestSay

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:8,代碼來源:talker_test.go

示例7: TestBadSides

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:8,代碼來源:dice_test.go

示例8: TestNonJoinEvent

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:8,代碼來源:talker_test.go

示例9: TestCounterOne

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.")
}
開發者ID:velour,項目名稱:catbase,代碼行數:8,代碼來源:counter_test.go

示例10: TestNotCommand

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:8,代碼來源:dice_test.go

示例11: TestReminderParse

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.")
}
開發者ID:velour,項目名稱:catbase,代碼行數:9,代碼來源:reminder_test.go

示例12: TestSayCommand

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")
}
開發者ID:velour,項目名稱:catbase,代碼行數:9,代碼來源:talker_test.go

示例13: TestNoSayings

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)
}
開發者ID:velour,項目名稱:catbase,代碼行數:9,代碼來源:talker_test.go

示例14: TestLotsOfDice

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.")
}
開發者ID:velour,項目名稱:catbase,代碼行數:9,代碼來源:dice_test.go

示例15: TestDice

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:")
}
開發者ID:velour,項目名稱:catbase,代碼行數:9,代碼來源:dice_test.go


注:本文中的github.com/velour/catbase/bot.NewMockBot函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。