Skip to content

Commit 535a66b

Browse files
committed
feat: removed deprecated interface BotRecordsMaker
1 parent 9504b9b commit 535a66b

File tree

2 files changed

+114
-118
lines changed

2 files changed

+114
-118
lines changed

botsfwmodels/bot_records_maker.go

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,61 @@ package botsfwmodels
33
// BotRecordsMaker is an interface for making bot records
44
// This should be implemented by platform adapters
55
// (for example, by https://github.com/bots-go-framework/bots-fw-telegram)
6-
type BotRecordsMaker interface {
7-
Platform() string
8-
9-
// MakeAppUserDto makes app user DTO for a given request sender
10-
MakeAppUserDto(botID string) (AppUserData, error)
11-
12-
// MakeBotUserDto makes bot user DTO for a given request sender
13-
MakeBotUserDto(botID string) (PlatformUserData, error)
14-
15-
// MakeBotChatDto makes bot chat DTO for a given request
16-
MakeBotChatDto(botID string) (BotChatData, error)
17-
}
18-
19-
func NewBotRecordsMaker(
20-
platform string,
21-
makeAppUserDto func(botID string) (appUser AppUserData, err error),
22-
makeBotUserDto func(botID string) (botUser PlatformUserData, err error),
23-
makeBotChatDto func(botID string) (botChat BotChatData, err error),
24-
) BotRecordsMaker {
25-
if makeAppUserDto == nil {
26-
panic("makeAppUserDto is nil")
27-
}
28-
if makeBotUserDto == nil {
29-
panic("makeBotUserDto is nil")
30-
}
31-
if makeBotChatDto == nil {
32-
panic("makeBotChatDto is nil")
33-
}
34-
return botRecordsMaker{
35-
platform: platform,
36-
makeAppUserDto: makeAppUserDto,
37-
makeBotUserDto: makeBotUserDto,
38-
makeBotChatDto: makeBotChatDto,
39-
}
40-
}
41-
42-
type botRecordsMaker struct {
43-
platform string
44-
makeAppUserDto func(botID string) (AppUserData, error)
45-
makeBotUserDto func(botID string) (PlatformUserData, error)
46-
makeBotChatDto func(botID string) (botChat BotChatData, err error)
47-
}
48-
49-
func (b botRecordsMaker) Platform() string {
50-
return b.platform
51-
}
52-
53-
func (b botRecordsMaker) MakeAppUserDto(botID string) (AppUserData, error) {
54-
return b.makeAppUserDto(botID)
55-
}
56-
57-
func (b botRecordsMaker) MakeBotUserDto(botID string) (PlatformUserData, error) {
58-
return b.makeBotUserDto(botID)
59-
}
60-
61-
func (b botRecordsMaker) MakeBotChatDto(botID string) (botChat BotChatData, err error) {
62-
return b.makeBotChatDto(botID)
63-
}
6+
//type BotRecordsMaker interface {
7+
// Platform() string
8+
//
9+
// // MakeAppUserDto makes app user DTO for a given request sender
10+
// MakeAppUserDto(botID string) (AppUserData, error)
11+
//
12+
// // MakeBotUserDto makes bot user DTO for a given request sender
13+
// MakeBotUserDto(botID string) (PlatformUserData, error)
14+
//
15+
// // MakeBotChatDto makes bot chat DTO for a given request
16+
// MakeBotChatDto(botID string) (BotChatData, error)
17+
//}
18+
//
19+
//func NewBotRecordsMaker(
20+
// platform string,
21+
// makeAppUserDto func(botID string) (appUser AppUserData, err error),
22+
// makeBotUserDto func(botID string) (botUser PlatformUserData, err error),
23+
// makeBotChatDto func(botID string) (botChat BotChatData, err error),
24+
//) BotRecordsMaker {
25+
// if makeAppUserDto == nil {
26+
// panic("makeAppUserDto is nil")
27+
// }
28+
// if makeBotUserDto == nil {
29+
// panic("makeBotUserDto is nil")
30+
// }
31+
// if makeBotChatDto == nil {
32+
// panic("makeBotChatDto is nil")
33+
// }
34+
// return botRecordsMaker{
35+
// platform: platform,
36+
// makeAppUserDto: makeAppUserDto,
37+
// makeBotUserDto: makeBotUserDto,
38+
// makeBotChatDto: makeBotChatDto,
39+
// }
40+
//}
41+
//
42+
//type botRecordsMaker struct {
43+
// platform string
44+
// makeAppUserDto func(botID string) (AppUserData, error)
45+
// makeBotUserDto func(botID string) (PlatformUserData, error)
46+
// makeBotChatDto func(botID string) (botChat BotChatData, err error)
47+
//}
48+
//
49+
//func (b botRecordsMaker) Platform() string {
50+
// return b.platform
51+
//}
52+
//
53+
//func (b botRecordsMaker) MakeAppUserDto(botID string) (AppUserData, error) {
54+
// return b.makeAppUserDto(botID)
55+
//}
56+
//
57+
//func (b botRecordsMaker) MakeBotUserDto(botID string) (PlatformUserData, error) {
58+
// return b.makeBotUserDto(botID)
59+
//}
60+
//
61+
//func (b botRecordsMaker) MakeBotChatDto(botID string) (botChat BotChatData, err error) {
62+
// return b.makeBotChatDto(botID)
63+
//}
Lines changed: 56 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,58 @@
11
package botsfwmodels
22

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 PlatformUserData, 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 PlatformUserData, 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-
}
3+
//func TestNewBotRecordsMaker(t *testing.T) {
4+
// type args struct {
5+
// platform string
6+
// makeAppUserDto func(botID string) (appUser AppUserData, err error)
7+
// makeBotUserDto func(botID string) (botUser PlatformUserData, err error)
8+
// makeBotChatDto func(botID string) (botChat BotChatData, err error)
9+
// }
10+
//
11+
// makeAppUserDto := func(botID string) (appUser AppUserData, err error) {
12+
// return nil, nil
13+
// }
14+
//
15+
// makeBotUserDto := func(botID string) (botUser PlatformUserData, err error) {
16+
// return nil, nil
17+
// }
18+
//
19+
// makeBotChatDto := func(botID string) (botChat BotChatData, err error) {
20+
// return nil, nil
21+
// }
22+
//
23+
// tests := []struct {
24+
// name string
25+
// args args
26+
// want BotRecordsMaker
27+
// }{
28+
// {
29+
// name: "TestNewBotRecordsMaker",
30+
// args: args{
31+
// platform: "test",
32+
// makeAppUserDto: makeAppUserDto,
33+
// makeBotUserDto: makeBotUserDto,
34+
// makeBotChatDto: makeBotChatDto,
35+
// },
36+
// want: botRecordsMaker{
37+
// platform: "test",
38+
// makeAppUserDto: makeAppUserDto,
39+
// makeBotUserDto: makeBotUserDto,
40+
// makeBotChatDto: makeBotChatDto,
41+
// },
42+
// },
43+
// }
44+
// for _, tt := range tests {
45+
// t.Run(tt.name, func(t *testing.T) {
46+
// got := NewBotRecordsMaker(tt.args.platform, tt.args.makeAppUserDto, tt.args.makeBotUserDto, tt.args.makeBotChatDto)
47+
// if _, err := got.MakeAppUserDto("test"); err != nil {
48+
// t.Error(err)
49+
// }
50+
// if _, err := got.MakeBotUserDto("test"); err != nil {
51+
// t.Error(err)
52+
// }
53+
// if _, err := got.MakeBotChatDto("test"); err != nil {
54+
// t.Error(err)
55+
// }
56+
// })
57+
// }
58+
//}

0 commit comments

Comments
 (0)