-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmins_test.go
87 lines (81 loc) · 1.47 KB
/
admins_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package hudorbot
import (
"testing"
"github.com/go-telegram-bot-api/telegram-bot-api"
"github.com/google/go-cmp/cmp"
)
func TestAdminKey(t *testing.T) {
testCases := []struct {
input int
output string
}{
{
100000,
"admin:100000",
},
{
-100000,
"admin:-100000",
},
{
0,
"admin:0",
},
}
for _, tc := range testCases {
output := adminKey(tc.input)
if output != tc.output {
t.Errorf("excpected admin key to be %s but received %s", tc.output, output)
}
}
}
func TestFindCreator(t *testing.T) {
testCases := []struct {
input []tgbotapi.ChatMember
output *tgbotapi.User
}{
{
input: []tgbotapi.ChatMember{},
output: nil,
},
{
input: []tgbotapi.ChatMember{
{
Status: "creator",
User: &tgbotapi.User{
ID: 100,
FirstName: "group",
LastName: "creator",
UserName: "group_creator",
},
},
},
output: &tgbotapi.User{
ID: 100,
FirstName: "group",
LastName: "creator",
UserName: "group_creator",
},
},
{
input: []tgbotapi.ChatMember{
{
Status: "member",
User: &tgbotapi.User{
ID: 100,
FirstName: "group member",
LastName: "member",
UserName: "group_member",
},
},
},
output: nil,
},
}
for _, tc := range testCases {
output := findCreator(tc.input)
if !cmp.Equal(output, tc.output) {
t.Errorf("excpected to creator be %#v but instead received %#v", tc.output, output)
}
}
}