-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands_test.go
More file actions
46 lines (38 loc) · 1.07 KB
/
Copy pathcommands_test.go
File metadata and controls
46 lines (38 loc) · 1.07 KB
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
package botapi
import (
"context"
"testing"
"github.com/gotd/td/tg"
)
func TestBotCommandScopeResolve(t *testing.T) {
ctx := context.Background()
cases := []struct {
scope BotCommandScope
want tg.BotCommandScopeClass
}{
{BotCommandScopeDefault(), &tg.BotCommandScopeDefault{}},
{BotCommandScopeAllPrivateChats(), &tg.BotCommandScopeUsers{}},
{BotCommandScopeAllGroupChats(), &tg.BotCommandScopeChats{}},
{BotCommandScopeAllChatAdministrators(), &tg.BotCommandScopeChatAdmins{}},
}
for _, c := range cases {
// The non-targeted variants ignore the *Bot receiver, so nil is fine.
got, err := c.scope.resolve(ctx, nil)
if err != nil {
t.Fatalf("resolve %T: %v", c.scope, err)
}
if got.TypeID() != c.want.TypeID() {
t.Fatalf("resolve %T: got %T, want %T", c.scope, got, c.want)
}
}
}
func TestCommandConfigDefaultScope(t *testing.T) {
var cfg commandConfig
scope, err := cfg.resolveScope(context.Background(), nil)
if err != nil {
t.Fatal(err)
}
if _, ok := scope.(*tg.BotCommandScopeDefault); !ok {
t.Fatalf("default scope: got %T", scope)
}
}