Skip to content

Commit bf32f78

Browse files
committed
chore: TestNewBotRecordsMaker
1 parent 8430cd2 commit bf32f78

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

botsfwmodels/bot_records_maker.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package botsfwmodels
22

33
// BotRecordsMaker is an interface for making bot records
44
// This should be implemented by platform adapters
5-
// (for example by https://github.com/bots-go-framework/bots-fw-telegram)
5+
// (for example, by https://github.com/bots-go-framework/bots-fw-telegram)
66
type BotRecordsMaker interface {
77
Platform() string
88

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package botsfwmodels
2+
3+
import (
4+
"testing"
5+
)
6+
7+
func TestNewBotRecordsMaker(t *testing.T) {
8+
type args struct {
9+
platform string
10+
makeAppUserDto func(botID string) (appUser AppUserData, err error)
11+
makeBotUserDto func(botID string) (botUser BotUserData, err error)
12+
makeBotChatDto func(botID string) (botChat BotChatData, err error)
13+
}
14+
15+
makeAppUserDto := func(botID string) (appUser AppUserData, err error) {
16+
return nil, nil
17+
}
18+
19+
makeBotUserDto := func(botID string) (botUser BotUserData, err error) {
20+
return nil, nil
21+
}
22+
23+
makeBotChatDto := func(botID string) (botChat BotChatData, err error) {
24+
return nil, nil
25+
}
26+
27+
tests := []struct {
28+
name string
29+
args args
30+
want BotRecordsMaker
31+
}{
32+
{
33+
name: "TestNewBotRecordsMaker",
34+
args: args{
35+
platform: "test",
36+
makeAppUserDto: makeAppUserDto,
37+
makeBotUserDto: makeBotUserDto,
38+
makeBotChatDto: makeBotChatDto,
39+
},
40+
want: botRecordsMaker{
41+
platform: "test",
42+
makeAppUserDto: makeAppUserDto,
43+
makeBotUserDto: makeBotUserDto,
44+
makeBotChatDto: makeBotChatDto,
45+
},
46+
},
47+
}
48+
for _, tt := range tests {
49+
t.Run(tt.name, func(t *testing.T) {
50+
got := NewBotRecordsMaker(tt.args.platform, tt.args.makeAppUserDto, tt.args.makeBotUserDto, tt.args.makeBotChatDto)
51+
if _, err := got.MakeAppUserDto("test"); err != nil {
52+
t.Error(err)
53+
}
54+
if _, err := got.MakeBotUserDto("test"); err != nil {
55+
t.Error(err)
56+
}
57+
if _, err := got.MakeBotChatDto("test"); err != nil {
58+
t.Error(err)
59+
}
60+
})
61+
}
62+
}

0 commit comments

Comments
 (0)