Skip to content

Commit b2958aa

Browse files
ernadoclaude
andcommitted
test: split grab-bag test files into topical ones
Replace the coverage_extra{,2,3} and *_cover catch-all test files with files named for what they cover: send_media, sticker_methods, builders, rich, send_invoice, chat_photo, download, option_methods, send_action, edit_media, convert_message, dispatch, inline_passport. Media-group, peer-ref and entities tests fold into their existing topical files; the shared sendMediaOK helper moves to the harness. No behaviour change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0232f05 commit b2958aa

20 files changed

Lines changed: 550 additions & 512 deletions

builders_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package botapi
2+
3+
import (
4+
"bytes"
5+
"testing"
6+
)
7+
8+
func TestBuilders(t *testing.T) {
9+
if kb := Keyboard(Row(Button("a"), ButtonContact("c")), Row(Button("b"))); len(kb.Keyboard) != 2 {
10+
t.Fatalf("keyboard = %#v", kb)
11+
}
12+
if ik := InlineKeyboard([]InlineKeyboardButton{InlineButtonData("x", "d"), InlineButtonURL("u", "https://e")}); len(ik.InlineKeyboard) != 1 {
13+
t.Fatalf("inline keyboard = %#v", ik)
14+
}
15+
for _, f := range []InputFile{
16+
FileID("id"), FileURL("https://e"), FileFromPath("/tmp/x"),
17+
FileFromBytes("n", []byte("d")), FileFromReader("n", bytes.NewReader(nil)),
18+
} {
19+
if f == nil {
20+
t.Fatal("nil input file")
21+
}
22+
}
23+
if e := Emoji("👍"); e == nil {
24+
t.Fatal("nil emoji reaction")
25+
}
26+
if e := CustomEmoji("123"); e == nil {
27+
t.Fatal("nil custom emoji reaction")
28+
}
29+
}

chat_photo_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package botapi
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/gotd/td/tg"
8+
)
9+
10+
func TestSetChatPhotoUpload(t *testing.T) {
11+
inv := newMockInvoker()
12+
inv.reply(tg.ChannelsEditPhotoRequestTypeID, okUpdates())
13+
b := newMockBot(inv)
14+
15+
err := b.SetChatPhoto(context.Background(), tdlibChannel(50), FileFromBytes("p.jpg", []byte("img")))
16+
if err != nil {
17+
t.Fatalf("SetChatPhoto: %v", err)
18+
}
19+
if !inv.called(tg.ChannelsEditPhotoRequestTypeID) {
20+
t.Fatal("expected channels.editPhoto")
21+
}
22+
}
23+
24+
func TestSetChatPhotoRejectsNonUpload(t *testing.T) {
25+
b := newMockBot(newMockInvoker())
26+
if err := b.SetChatPhoto(context.Background(), tdlibChannel(50), FileID("x")); err == nil {
27+
t.Fatal("SetChatPhoto should reject a non-uploaded file")
28+
}
29+
}

coverage_extra2_test.go

Lines changed: 0 additions & 204 deletions
This file was deleted.

0 commit comments

Comments
 (0)