This repository was archived by the owner on Dec 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_test.go
62 lines (50 loc) · 1.43 KB
/
context_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package drouter_test
import (
"github.com/NyanKiyoshi/disgord-plugin-router"
"github.com/NyanKiyoshi/disgord-plugin-router/mocks/mocked_disgord"
"github.com/andersfylling/disgord"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/assert"
"testing"
)
var channelID = disgord.NewSnowflake(123)
var selfUserID = disgord.NewSnowflake(456)
func createDummyMessage() *disgord.Message {
return &disgord.Message{
ChannelID: channelID,
Author: &disgord.User{
ID: selfUserID,
},
Content: "hello",
}
}
func createDummyContext(session *mocked_disgord.MockrouterSession) *drouter.Context {
return &drouter.Context{
Message: createDummyMessage(),
Session: session,
}
}
func TestContext_Say(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
const messageToSend = "Hello world"
mockedSession := mocked_disgord.NewMockrouterSession(mockCtrl)
mockedSession.
EXPECT().
SendMsgString(channelID, messageToSend).
Return(nil, nil)
ctx := createDummyContext(mockedSession)
assert.Nil(t, ctx.Say("Hello world"))
}
func TestContext_SayComplex(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
var messageToSend = &disgord.Message{}
mockedSession := mocked_disgord.NewMockrouterSession(mockCtrl)
mockedSession.
EXPECT().
SendMsg(channelID, messageToSend).
Return(nil, nil)
ctx := createDummyContext(mockedSession)
assert.Nil(t, ctx.SayComplex(messageToSend))
}