fix: sync birthday updates and system sticker sets
This commit is contained in:
parent
c38dd73fdd
commit
ddcf2d31ca
10 changed files with 431 additions and 35 deletions
68
cmd/stickerfetch/main_test.go
Normal file
68
cmd/stickerfetch/main_test.go
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/gotd/td/tg"
|
||||
)
|
||||
|
||||
func TestSpecToInputSystemSets(t *testing.T) {
|
||||
tests := []struct {
|
||||
spec string
|
||||
label string
|
||||
want any
|
||||
}{
|
||||
{"emoji_default_statuses", "EmojiDefaultStatuses", &tg.InputStickerSetEmojiDefaultStatuses{}},
|
||||
{"emoji_channel_default_statuses", "EmojiChannelDefaultStatuses", &tg.InputStickerSetEmojiChannelDefaultStatuses{}},
|
||||
{"emoji_default_topic_icons", "EmojiDefaultTopicIcons", &tg.InputStickerSetEmojiDefaultTopicIcons{}},
|
||||
{"premium_gifts", "PremiumGifts", &tg.InputStickerSetPremiumGifts{}},
|
||||
{"ton_gifts", "TonGifts", &tg.InputStickerSetTonGifts{}},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.spec, func(t *testing.T) {
|
||||
input, label, err := specToInput(tt.spec)
|
||||
if err != nil {
|
||||
t.Fatalf("specToInput: %v", err)
|
||||
}
|
||||
if label != tt.label {
|
||||
t.Fatalf("label = %q, want %q", label, tt.label)
|
||||
}
|
||||
if got, want := fmt.Sprintf("%T", input), fmt.Sprintf("%T", tt.want); got != want {
|
||||
t.Fatalf("input = %s, want %s", got, want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSpecToInputShortName(t *testing.T) {
|
||||
input, label, err := specToInput("short:FestiveFontEmoji")
|
||||
if err != nil {
|
||||
t.Fatalf("specToInput short: %v", err)
|
||||
}
|
||||
short, ok := input.(*tg.InputStickerSetShortName)
|
||||
if !ok {
|
||||
t.Fatalf("input = %T, want short name", input)
|
||||
}
|
||||
if short.ShortName != "FestiveFontEmoji" || label != "FestiveFontEmoji" {
|
||||
t.Fatalf("short input = (%q, %q), want FestiveFontEmoji", short.ShortName, label)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCompleteExistingFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "doc.tgs")
|
||||
if completeExistingFile(path, 4) {
|
||||
t.Fatal("missing file reported complete")
|
||||
}
|
||||
if err := os.WriteFile(path, []byte("tgs!"), 0o644); err != nil {
|
||||
t.Fatalf("write temp doc: %v", err)
|
||||
}
|
||||
if !completeExistingFile(path, 4) {
|
||||
t.Fatal("matching file reported incomplete")
|
||||
}
|
||||
if completeExistingFile(path, 5) {
|
||||
t.Fatal("mismatched file reported complete")
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue