-
Notifications
You must be signed in to change notification settings - Fork 26
/
querybuilder_test.go
72 lines (60 loc) · 1.37 KB
/
querybuilder_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
package echotron
import (
"net/url"
"reflect"
"testing"
)
type scanTest struct {
i any
predefined url.Values
expected url.Values
}
func TestScan(t *testing.T) {
tests := []scanTest{
{
i: CommandOptions{
LanguageCode: "it",
Scope: BotCommandScope{Type: BCSTChat, ChatID: 33288},
},
predefined: url.Values{"foo": {"bar"}},
expected: url.Values{
"foo": {"bar"},
"language_code": {"it"},
"scope": {`{"type":"chat","chat_id":33288,"user_id":0}`},
},
},
}
for i, tt := range tests {
result := scan(tt.i, tt.predefined)
if !reflect.DeepEqual(tt.expected, result) {
t.Fatalf("test #%d: result differs from expected value\n", i)
}
}
}
func TestToStringDefault(t *testing.T) {
ret := toString(reflect.ValueOf(nil))
if ret != "" {
t.Fatalf("expected empty string, got %+v", ret)
}
}
func TestUrlValues(t *testing.T) {
ret := urlValues(nil)
if ret != nil {
t.Fatalf("expected nil, got %+v", ret)
}
}
func TestAddValues(t *testing.T) {
vals := url.Values{}
ret := addValues(vals, nil)
if !reflect.DeepEqual(vals, ret) {
t.Fatalf("expected nil, got %+v", ret)
}
}
func TestAddValuesNil(t *testing.T) {
opts := MessageOptions{ParseMode: MarkdownV2}
vals := urlValues(opts)
ret := addValues(nil, opts)
if !reflect.DeepEqual(vals, ret) {
t.Fatalf("expected %+v, got %+v", vals, ret)
}
}