Merge pull request #14 from cgrinds/master

Added testdata and test for CDATA bug
This commit is contained in:
jimt 2013-03-28 13:13:05 -07:00
commit 3f18008689
2 changed files with 40 additions and 0 deletions

View File

@ -56,6 +56,18 @@ func Test_RssAuthor(t *testing.T) {
}
}
func Test_CData(t *testing.T) {
content, _ := ioutil.ReadFile("testdata/iosBoardGameGeek.rss")
feed := New(1, true, chanHandler, itemHandler)
feed.FetchBytes("http://example.com", content, nil)
item := items[0]
expected := `<p>abc<div>"def"</div>ghi`
if item.Description != expected {
t.Errorf("Expected item.Description to be [%s] but item.Description=[%s]", expected, item.Description)
}
}
func chanHandler(feed *Feed, newchannels []*Channel) {
println(len(newchannels), "new channel(s) in", feed.Url)
}

28
testdata/iosBoardGameGeek.rss vendored Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0"?><rss version="2.0"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>iOS Board Games | BoardGameGeek</title>
<image>
<url>http://geekdo-images.com/images/geeksm.gif</url>
<link>http://boardgamegeek.com/</link>
<title>iOS Board Games | BoardGameGeek</title>
</image>
<description>BoardGameGeek features information related to the board gaming hobby</description>
<language>en-us</language>
<pubDate>Thu, 28 Mar 2013 14:51:20 +0000</pubDate>
<lastBuildDate>Thu, 28 Mar 2013 14:51:20 +0000</lastBuildDate>
<link>http://boardgamegeek.com/</link>
<webMaster>webmaster@boardgamegeek.com</webMaster>
<item>
<title>iOS News: Stone Age 2.0 Released, Ravensburger March Sale Features San Juan, More Info on Las Vegas, Shifts Gets an Update and more...</title>
<description>&lt;p&gt;abc<![CDATA[<div>"def"</div>]]>ghi
</description>
<link>http://boardgamegeek.com/blogpost/18194/ios-news-stone-age-2-0-released-ravensburger-march</link>
<guid>http://boardgamegeek.com/blogpost/18194/ios-news-stone-age-2-0-released-ravensburger-march</guid>
<pubDate>Thu, 28 Mar 2013 14:51:20 +0000</pubDate>
<dc:creator>Neumannium</dc:creator>
</item>
</channel>
</rss>