diff options
| author | 2023-02-25 04:52:45 +0000 | |
|---|---|---|
| committer | 2023-02-24 20:52:45 -0800 | |
| commit | 8f9ccc6540be9d637b812985936f064bada8fcf3 (patch) | |
| tree | 7d098af52e1f8946c1cd26ee214307b276b5f273 /reader/json/parser_test.go | |
| parent | ff8d68c151645de62d48fba62d2f591eab8f7383 (diff) | |
| download | v2-8f9ccc6540be9d637b812985936f064bada8fcf3.tar.gz v2-8f9ccc6540be9d637b812985936f064bada8fcf3.tar.zst v2-8f9ccc6540be9d637b812985936f064bada8fcf3.zip | |
Parse `<category>` from Feeds (RSS, Atom and JSON)
Diffstat (limited to 'reader/json/parser_test.go')
| -rw-r--r-- | reader/json/parser_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/reader/json/parser_test.go b/reader/json/parser_test.go index 5ba82d45..186baca6 100644 --- a/reader/json/parser_test.go +++ b/reader/json/parser_test.go @@ -575,3 +575,45 @@ func TestParseInvalidJSON(t *testing.T) { t.Error("Parse should returns an error") } } + +func TestParseTags(t *testing.T) { + data := `{ + "version": "https://jsonfeed.org/version/1", + "user_comment": "This is a microblog feed. You can add this to your feed reader using the following URL: https://example.org/feed.json", + "title": "Brent Simmons’s Microblog", + "home_page_url": "https://example.org/", + "feed_url": "https://example.org/feed.json", + "author": { + "name": "Brent Simmons", + "url": "http://example.org/", + "avatar": "https://example.org/avatar.png" + }, + "items": [ + { + "id": "2347259", + "url": "https://example.org/2347259", + "content_text": "Cats are neat. \n\nhttps://example.org/cats", + "date_published": "2016-02-09T14:22:00-07:00", + "tags": [ + "tag 1", + "tag 2" + ] + } + ] + }` + + feed, err := Parse("https://example.org/feed.json", bytes.NewBufferString(data)) + if err != nil { + t.Fatal(err) + } + + if len(feed.Entries[0].Tags) != 2 { + t.Errorf("Incorrect number of Tags, got: %d", len(feed.Entries[0].Tags)) + } + + expected := "tag 2" + result := feed.Entries[0].Tags[1] + if result != expected { + t.Errorf("Incorrect entry tag, got %q instead of %q", result, expected) + } +} |
