all repos

rss-tools @ 610059f

get rss feed from sources that(i need and) dont provide one

rss-tools/sources/telegram/telegram_test.go (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
telegram: include image caption, 1 month ago
1
package telegram
2
3
import (
4
	"strings"
5
	"testing"
6
	"time"
7
8
	"olexsmir.xyz/x/is"
9
)
10
11
func TestFeedEntryFromMessageWithImage(t *testing.T) {
12
	msg := &Message{
13
		MessageID:     42,
14
		Caption:       "hello <world>",
15
		Date:          time.Date(2026, 4, 22, 19, 38, 0, 0, time.UTC).Unix(),
16
		PhotoBase64:   "YWJj",
17
		PhotoMIMEType: "image/png",
18
	}
19
20
	entry := feedEntryFromMessage(msg)
21
	is.Equal(t, "🖼️ [2026-04-22]", entry.Title)
22
	is.Equal(t, "html", entry.ContentType)
23
	if !strings.Contains(entry.Content, "<p>hello &lt;world&gt;</p>") {
24
		t.Fatalf("expected escaped text in image entry: %s", entry.Content)
25
	}
26
	if !strings.Contains(entry.Content, `src="data:image/png;base64,YWJj"`) {
27
		t.Fatalf("expected image data URI in image entry: %s", entry.Content)
28
	}
29
}
30
31
func TestFeedEntryFromMessageTextOnly(t *testing.T) {
32
	msg := &Message{
33
		MessageID: 11,
34
		Text:      "plain text",
35
		Date:      time.Date(2026, 4, 22, 19, 38, 0, 0, time.UTC).Unix(),
36
	}
37
38
	entry := feedEntryFromMessage(msg)
39
	is.Equal(t, "plain text", entry.Title)
40
	is.Equal(t, "", entry.ContentType)
41
	is.Equal(t, "plain text", entry.Content)
42
}