-
-
Notifications
You must be signed in to change notification settings - Fork 116
/
article_test.go
42 lines (36 loc) · 992 Bytes
/
article_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
package inline
import (
"context"
"testing"
"github.com/gotd/td/bin"
"github.com/gotd/td/tg"
)
func TestArticle(t *testing.T) {
ctx := context.Background()
builder, mock := testBuilder(t)
mock.ExpectFunc(func(b bin.Encoder) {
v, ok := b.(*tg.MessagesSetInlineBotResultsRequest)
mock.True(ok)
mock.Equal(int64(10), v.QueryID)
for i := range v.Results {
r, ok := v.Results[i].(*tg.InputBotInlineResult)
mock.True(ok)
mock.NotEmpty(r.ID)
mock.Equal(r.Title, r.Type)
mock.Equal(r.Description, r.Title)
mock.Equal(r.URL, r.Description)
}
}).ThenTrue()
_, err := builder.Set(ctx,
Article(ArticleType, MessageText("article")).
Description(ArticleType).URL(ArticleType),
Article(ArticleType, MediaAuto("article")).ID("10").Title(ArticleType).
Description(ArticleType).URL(ArticleType),
)
mock.NoError(err)
mock.Expect().ThenRPCErr(testRPCError())
_, err = builder.Set(ctx,
Article(ArticleType, MessageText("article")),
)
mock.Error(err)
}