|
@@ -15,6 +15,8 @@ func TestParseJsonFeed(t *testing.T) {
|
|
|
data := `{
|
|
data := `{
|
|
|
"version": "https://jsonfeed.org/version/1",
|
|
"version": "https://jsonfeed.org/version/1",
|
|
|
"title": "My Example Feed",
|
|
"title": "My Example Feed",
|
|
|
|
|
+ "icon": "https://micro.blog/jsonfeed/avatar.jpg",
|
|
|
|
|
+ "favicon": "https://micro.blog/jsonfeed/favicon.png",
|
|
|
"home_page_url": "https://example.org/",
|
|
"home_page_url": "https://example.org/",
|
|
|
"feed_url": "https://example.org/feed.json",
|
|
"feed_url": "https://example.org/feed.json",
|
|
|
"items": [
|
|
"items": [
|
|
@@ -48,6 +50,10 @@ func TestParseJsonFeed(t *testing.T) {
|
|
|
t.Errorf("Incorrect site URL, got: %s", feed.SiteURL)
|
|
t.Errorf("Incorrect site URL, got: %s", feed.SiteURL)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if feed.IconURL != "https://micro.blog/jsonfeed/avatar.jpg" {
|
|
|
|
|
+ t.Errorf("Incorrect icon URL, got: %s", feed.IconURL)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if len(feed.Entries) != 2 {
|
|
if len(feed.Entries) != 2 {
|
|
|
t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries))
|
|
t.Errorf("Incorrect number of entries, got: %d", len(feed.Entries))
|
|
|
}
|
|
}
|
|
@@ -617,3 +623,33 @@ func TestParseTags(t *testing.T) {
|
|
|
t.Errorf("Incorrect entry tag, got %q instead of %q", result, expected)
|
|
t.Errorf("Incorrect entry tag, got %q instead of %q", result, expected)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func TestParseFavicon(t *testing.T) {
|
|
|
|
|
+ data := `{
|
|
|
|
|
+ "version": "https://jsonfeed.org/version/1",
|
|
|
|
|
+ "title": "My Example Feed",
|
|
|
|
|
+ "favicon": "https://micro.blog/jsonfeed/favicon.png",
|
|
|
|
|
+ "home_page_url": "https://example.org/",
|
|
|
|
|
+ "feed_url": "https://example.org/feed.json",
|
|
|
|
|
+ "items": [
|
|
|
|
|
+ {
|
|
|
|
|
+ "id": "2",
|
|
|
|
|
+ "content_text": "This is a second item.",
|
|
|
|
|
+ "url": "https://example.org/second-item"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "id": "1",
|
|
|
|
|
+ "content_html": "<p>Hello, world!</p>",
|
|
|
|
|
+ "url": "https://example.org/initial-post"
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ }`
|
|
|
|
|
+
|
|
|
|
|
+ feed, err := Parse("https://example.org/feed.json", bytes.NewBufferString(data))
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ t.Fatal(err)
|
|
|
|
|
+ }
|
|
|
|
|
+ if feed.IconURL != "https://micro.blog/jsonfeed/favicon.png" {
|
|
|
|
|
+ t.Errorf("Incorrect icon URL, got: %s", feed.IconURL)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|