Skip to content

Commit

Permalink
mmcdole#151 Testcase for atom author in RSS
Browse files Browse the repository at this point in the history
  • Loading branch information
Necoro committed Aug 22, 2020
1 parent b4788a4 commit 6835f06
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"items": [
{
"author": {
"name": "Item Author"
},
"extensions": {
"atom": {
"author": [
{
"name": "author",
"value": "",
"parsed": {
"authors": [
{
"name": "Item Author"
}
]
}
}
]
}
}
}
],
"feedType": "rss",
"feedVersion": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!--
Description: rss item with atom author
-->
<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom">
<channel>
<item>
<a10:author><a10:name>Item Author</a10:name></a10:author>
</item>
</channel>
</rss>
11 changes: 10 additions & 1 deletion translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ func TestDefaultRSSTranslator_Translate(t *testing.T) {
// Parse actual feed
translator := &gofeed.DefaultRSSTranslator{}
fp := &rss.Parser{}
rssFeed, _ := fp.Parse(f)
rssFeed, _ := fp.Parse(f, gofeed.NewParser().BuildRSSExtParsers())
actual, _ := translator.Translate(rssFeed)

// the `Parsed` part of extensions is not correctly unmarshalled from JSON
// workaround: move the actual extensions through a round of json marshalling so that we get the same
for _, i := range actual.Items {
if len(i.Extensions) > 0 {
b, _ := json.Marshal(i.Extensions)
json.Unmarshal(b, &i.Extensions)
}
}

// Get json encoded expected feed result
ef := fmt.Sprintf("testdata/translator/rss/%s.json", name)
e, _ := ioutil.ReadFile(ef)
Expand Down

0 comments on commit 6835f06

Please sign in to comment.