|
| 1 | +package botapi |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "testing" |
| 6 | + |
| 7 | + "github.com/gotd/td/tg" |
| 8 | +) |
| 9 | + |
| 10 | +func TestGetForumTopicIconStickers(t *testing.T) { |
| 11 | + inv := newMockInvoker() |
| 12 | + inv.reply(tg.MessagesGetStickerSetRequestTypeID, &tg.MessagesStickerSet{ |
| 13 | + Set: tg.StickerSet{ShortName: "topics", Emojis: true}, |
| 14 | + Documents: []tg.DocumentClass{ |
| 15 | + &tg.Document{ |
| 16 | + ID: 1, |
| 17 | + MimeType: "image/webp", |
| 18 | + Attributes: []tg.DocumentAttributeClass{ |
| 19 | + &tg.DocumentAttributeSticker{Alt: "🎯", Stickerset: &tg.InputStickerSetEmpty{}}, |
| 20 | + }, |
| 21 | + }, |
| 22 | + }, |
| 23 | + }) |
| 24 | + |
| 25 | + stickers, err := newMockBot(inv).GetForumTopicIconStickers(context.Background()) |
| 26 | + if err != nil { |
| 27 | + t.Fatalf("GetForumTopicIconStickers: %v", err) |
| 28 | + } |
| 29 | + |
| 30 | + if len(stickers) != 1 || stickers[0].Type != StickerCustomEmoji { |
| 31 | + t.Fatalf("stickers = %#v", stickers) |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +func TestSetStickerSetThumbnail(t *testing.T) { |
| 36 | + fid := documentFileID(t, 0x61) |
| 37 | + |
| 38 | + inv := newMockInvoker() |
| 39 | + inv.reply(tg.StickersSetStickerSetThumbRequestTypeID, &tg.MessagesStickerSet{Set: tg.StickerSet{ShortName: "s"}}) |
| 40 | + |
| 41 | + if err := newMockBot(inv).SetStickerSetThumbnail(context.Background(), "s", FileID(fid), StickerFormatStatic); err != nil { |
| 42 | + t.Fatalf("SetStickerSetThumbnail: %v", err) |
| 43 | + } |
| 44 | + |
| 45 | + var req tg.StickersSetStickerSetThumbRequest |
| 46 | + |
| 47 | + inv.decode(t, tg.StickersSetStickerSetThumbRequestTypeID, &req) |
| 48 | + |
| 49 | + if _, ok := req.GetThumb(); !ok { |
| 50 | + t.Fatal("thumb not set") |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +func TestSetCustomEmojiStickerSetThumbnail(t *testing.T) { |
| 55 | + inv := newMockInvoker() |
| 56 | + inv.reply(tg.StickersSetStickerSetThumbRequestTypeID, &tg.MessagesStickerSet{Set: tg.StickerSet{ShortName: "s"}}) |
| 57 | + |
| 58 | + if err := newMockBot(inv).SetCustomEmojiStickerSetThumbnail(context.Background(), "s", "777"); err != nil { |
| 59 | + t.Fatalf("SetCustomEmojiStickerSetThumbnail: %v", err) |
| 60 | + } |
| 61 | + |
| 62 | + var req tg.StickersSetStickerSetThumbRequest |
| 63 | + |
| 64 | + inv.decode(t, tg.StickersSetStickerSetThumbRequestTypeID, &req) |
| 65 | + |
| 66 | + if id, ok := req.GetThumbDocumentID(); !ok || id != 777 { |
| 67 | + t.Fatalf("thumb document id = %d, ok=%v", id, ok) |
| 68 | + } |
| 69 | +} |
0 commit comments