1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-07-02 16:38:37 +00:00

Take RSS TTL field into consideration to schedule next check date

This commit is contained in:
Frédéric Guillot 2023-10-20 19:39:32 -07:00
parent ed35555d74
commit 5e6c054345
5 changed files with 105 additions and 11 deletions

View file

@ -1500,3 +1500,51 @@ func TestParseEntryWithCategoryAndCDATA(t *testing.T) {
t.Errorf("Incorrect entry category, got %q instead of %q", result, expected)
}
}
func TestParseFeedWithTTLField(t *testing.T) {
data := `<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Example</title>
<link>https://example.org/</link>
<ttl>60</ttl>
<item>
<title>Test</title>
<link>https://example.org/item</link>
</item>
</channel>
</rss>`
feed, err := Parse("https://example.org/", bytes.NewBufferString(data))
if err != nil {
t.Fatal(err)
}
if feed.TTL != 60 {
t.Errorf("Incorrect TTL, got: %d", feed.TTL)
}
}
func TestParseFeedWithIncorrectTTLValue(t *testing.T) {
data := `<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Example</title>
<link>https://example.org/</link>
<ttl>invalid</ttl>
<item>
<title>Test</title>
<link>https://example.org/item</link>
</item>
</channel>
</rss>`
feed, err := Parse("https://example.org/", bytes.NewBufferString(data))
if err != nil {
t.Fatal(err)
}
if feed.TTL != 0 {
t.Errorf("Incorrect TTL, got: %d", feed.TTL)
}
}