1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-06-27 16:36:00 +00:00

Ignore enclosures without URL

This commit is contained in:
Frédéric Guillot 2020-01-30 21:08:11 -08:00
parent cb494ac416
commit 997e9422eb
9 changed files with 144 additions and 12 deletions

View file

@ -33,7 +33,7 @@ func TestParseJsonFeed(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if feed.Title != "My Example Feed" {
@ -115,7 +115,7 @@ func TestParsePodcast(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if feed.Title != "The Record" {
@ -131,7 +131,7 @@ func TestParsePodcast(t *testing.T) {
}
if len(feed.Entries) != 1 {
t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries))
t.Fatalf("Incorrect number of entries, got: %d", len(feed.Entries))
}
if feed.Entries[0].Hash != "6b678e57962a1b001e4e873756563cdc08bbd06ca561e764e0baa9a382485797" {
@ -156,7 +156,7 @@ func TestParsePodcast(t *testing.T) {
}
if len(feed.Entries[0].Enclosures) != 1 {
t.Errorf("Incorrect number of enclosures, got: %d", len(feed.Entries[0].Enclosures))
t.Fatalf("Incorrect number of enclosures, got: %d", len(feed.Entries[0].Enclosures))
}
if feed.Entries[0].Enclosures[0].URL != "http://therecord.co/downloads/The-Record-sp1e1-ChrisParrish.m4a" {
@ -172,6 +172,45 @@ func TestParsePodcast(t *testing.T) {
}
}
func TestParseEntryWithoutAttachmentURL(t *testing.T) {
data := `{
"version": "https://jsonfeed.org/version/1",
"user_comment": "This is a podcast feed. You can add this feed to your podcast client using the following URL: http://therecord.co/feed.json",
"title": "The Record",
"home_page_url": "http://therecord.co/",
"feed_url": "http://therecord.co/feed.json",
"items": [
{
"id": "http://therecord.co/chris-parrish",
"title": "Special #1 - Chris Parrish",
"url": "http://therecord.co/chris-parrish",
"content_text": "Chris has worked at Adobe and as a founder of Rogue Sheep, which won an Apple Design Award for Postage. Chriss new company is Aged & Distilled with Guy English — which shipped Napkin, a Mac app for visual collaboration. Chris is also the co-host of The Record. He lives on Bainbridge Island, a quick ferry ride from Seattle.",
"date_published": "2014-05-09T14:04:00-07:00",
"attachments": [
{
"url": "",
"mime_type": "audio/x-m4a",
"size_in_bytes": 0
}
]
}
]
}`
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Fatal(err)
}
if len(feed.Entries) != 1 {
t.Fatalf("Incorrect number of entries, got: %d", len(feed.Entries))
}
if len(feed.Entries[0].Enclosures) != 0 {
t.Errorf("Incorrect number of enclosures, got: %d", len(feed.Entries[0].Enclosures))
}
}
func TestParseFeedWithRelativeURL(t *testing.T) {
data := `{
"version": "https://jsonfeed.org/version/1",
@ -189,7 +228,7 @@ func TestParseFeedWithRelativeURL(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if feed.Entries[0].URL != "https://example.org/something.html" {
@ -221,7 +260,7 @@ func TestParseAuthor(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if len(feed.Entries) != 1 {
@ -250,7 +289,7 @@ func TestParseFeedWithoutTitle(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if feed.Title != "https://example.org/" {
@ -276,7 +315,7 @@ func TestParseFeedItemWithInvalidDate(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if len(feed.Entries) != 1 {
@ -304,7 +343,7 @@ func TestParseFeedItemWithoutID(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if len(feed.Entries) != 1 {
@ -331,7 +370,7 @@ func TestParseFeedItemWithoutTitle(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if len(feed.Entries) != 1 {
@ -358,7 +397,7 @@ func TestParseTruncateItemTitle(t *testing.T) {
feed, err := Parse(bytes.NewBufferString(data))
if err != nil {
t.Error(err)
t.Fatal(err)
}
if len(feed.Entries) != 1 {