1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-06 17:41:00 +00:00

test(reader): ensure consistent tags parsing across feed formats

This commit is contained in:
Frédéric Guillot 2025-07-07 20:00:04 -07:00
parent d6d18a2d61
commit 2e26f5ca75
7 changed files with 98 additions and 70 deletions

View file

@ -1971,6 +1971,9 @@ func TestParseEntryWithCategories(t *testing.T) {
<link>https://example.org/item</link>
<category>Category 1</category>
<category><![CDATA[Category 2]]></category>
<category>Category 2</category>
<category>Category 0</category>
<category> </category>
</item>
</channel>
</rss>`
@ -1980,11 +1983,11 @@ func TestParseEntryWithCategories(t *testing.T) {
t.Fatal(err)
}
if len(feed.Entries[0].Tags) != 2 {
if len(feed.Entries[0].Tags) != 3 {
t.Fatalf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags))
}
expected := []string{"Category 1", "Category 2"}
expected := []string{"Category 0", "Category 1", "Category 2"}
result := feed.Entries[0].Tags
for i, tag := range result {
@ -2022,7 +2025,7 @@ func TestParseFeedWithItunesCategories(t *testing.T) {
t.Errorf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags))
}
expected := []string{"Society & Culture", "Documentary", "Health", "Mental Health"}
expected := []string{"Documentary", "Health", "Mental Health", "Society & Culture"}
result := feed.Entries[0].Tags
for i, tag := range result {
@ -2091,12 +2094,12 @@ func TestParseEntryWithMediaCategories(t *testing.T) {
t.Errorf("Incorrect number of tags, got: %d", len(feed.Entries[0].Tags))
}
expected := []string{"Visual Art", "Ace Ventura - Pet Detective"}
expected := []string{"Ace Ventura - Pet Detective", "Visual Art"}
result := feed.Entries[0].Tags
for i, tag := range result {
if tag != expected[i] {
t.Errorf("Incorrect tag, got: %q", tag)
t.Errorf("Incorrect entry tag, got %q instead of %q", tag, expected[i])
}
}
}