File tree Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Expand file tree Collapse file tree 3 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "items" : [
3+ {
4+ "author" : {
5+ "name" : " Item Author"
6+ },
7+ "authors" : [
8+ {
9+ "name" : " Item Author"
10+ }
11+ ],
12+ "extensions" : {
13+ "atom" : {
14+ "author" : [
15+ {
16+ "name" : " author" ,
17+ "value" : " " ,
18+ "parsed" : {
19+ "authors" : [
20+ {
21+ "name" : " Item Author"
22+ }
23+ ]
24+ }
25+ }
26+ ]
27+ }
28+ }
29+ }
30+ ],
31+ "feedType" : " rss" ,
32+ "feedVersion" : " 2.0"
33+ }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff 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 , _ := jsonEncoding .Marshal (i .Extensions )
43+ jsonEncoding .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 )
You can’t perform that action at this time.
0 commit comments