forked from go-telegram/bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_test.go
55 lines (42 loc) · 1.08 KB
/
message_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
package models
import "testing"
func TestUnmarshalMaybeInaccessibleMessage_inaccessible(t *testing.T) {
src := `{"date":0,"chat":{"id":123},"message_id":987}`
mim := MaybeInaccessibleMessage{}
err := mim.UnmarshalJSON([]byte(src))
if err != nil {
t.Fatal(err)
}
if mim.Type != MaybeInaccessibleMessageTypeInaccessibleMessage {
t.Fatal("wrong type")
}
if mim.InaccessibleMessage == nil {
t.Fatal("InaccessibleMessage is nil")
}
if mim.InaccessibleMessage.Chat.ID != 123 {
t.Fatal("wrong chat id")
}
if mim.InaccessibleMessage.MessageID != 987 {
t.Fatal("wrong message id")
}
}
func TestUnmarshalMaybeInaccessibleMessage_message(t *testing.T) {
src := `{"date":42,"chat":{"id":123},"message_id":987}`
mim := MaybeInaccessibleMessage{}
err := mim.UnmarshalJSON([]byte(src))
if err != nil {
t.Fatal(err)
}
if mim.Type != MaybeInaccessibleMessageTypeMessage {
t.Fatal("wrong type")
}
if mim.Message == nil {
t.Fatal("Message is nil")
}
if mim.Message.Chat.ID != 123 {
t.Fatal("wrong chat id")
}
if mim.Message.ID != 987 {
t.Fatal("wrong message id")
}
}