Skip to content

Commit 68f7504

Browse files
committed
#151 Testcase for atom author in RSS
1 parent fcd4f80 commit 68f7504

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"items": [
3+
{
4+
"author": {
5+
"name": "Item Author"
6+
},
7+
"extensions": {
8+
"atom": {
9+
"author": [
10+
{
11+
"name": "author",
12+
"value": "",
13+
"parsed": {
14+
"authors": [
15+
{
16+
"name": "Item Author"
17+
}
18+
]
19+
}
20+
}
21+
]
22+
}
23+
}
24+
}
25+
],
26+
"feedType": "rss",
27+
"feedVersion": "2.0"
28+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!--
2+
Description: rss item with atom author
3+
-->
4+
<rss version="2.0" xmlns:a10="http://www.w3.org/2005/Atom">
5+
<channel>
6+
<item>
7+
<a10:author><a10:name>Item Author</a10:name></a10:author>
8+
</item>
9+
</channel>
10+
</rss>

translator_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,18 @@ func TestDefaultRSSTranslator_Translate(t *testing.T) {
3232
// Parse actual feed
3333
translator := &gofeed.DefaultRSSTranslator{}
3434
fp := &rss.Parser{}
35-
rssFeed, _ := fp.Parse(f)
35+
rssFeed, _ := fp.Parse(f, gofeed.NewParser().BuildRSSExtParsers())
3636
actual, _ := translator.Translate(rssFeed)
3737

38+
// the `Parsed` part of extensions is not correctly unmarshalled from JSON
39+
// workaround: move the actual extensions through a round of json marshalling so that we get the same
40+
for _, i := range actual.Items {
41+
if len(i.Extensions) > 0 {
42+
b, _ := json.Marshal(i.Extensions)
43+
json.Unmarshal(b, &i.Extensions)
44+
}
45+
}
46+
3847
// Get json encoded expected feed result
3948
ef := fmt.Sprintf("testdata/translator/rss/%s.json", name)
4049
e, _ := ioutil.ReadFile(ef)

0 commit comments

Comments
 (0)