test conservatives feed

This commit is contained in:
Duke 2014-01-18 14:35:00 -02:00
parent 269db380a3
commit a3882284e0
2 changed files with 88 additions and 0 deletions

View File

@ -88,6 +88,26 @@ func Test_CData(t *testing.T) {
} }
} }
func Test_Link(t *testing.T) {
content, _ := ioutil.ReadFile("testdata/ignoredLink.rss")
feed := New(1, true, chanHandler, itemHandler)
feed.FetchBytes("http://example.com", content, nil)
channel := feed.Channels[0]
item := channel.Items[0]
channelLinkExpected := "http://www.conservatives.com/XMLGateway/RSS/News.xml"
itemLinkExpected := "http://www.conservatives.com/News/News_stories/2013/09/Dr_Tania_Mathias_chosen_to_stand_up_for_local_people_in_Twickenham.aspx"
if channel.Links[0].Href != channelLinkExpected {
t.Errorf("Expected author to be %s but found %s", channelLinkExpected, channel.Links[0].Href)
}
if item.Links[0].Href != itemLinkExpected {
t.Errorf("Expected author to be %s but found %s", itemLinkExpected, item.Links[0].Href)
}
}
func chanHandler(feed *Feed, newchannels []*Channel) { func chanHandler(feed *Feed, newchannels []*Channel) {
println(len(newchannels), "new channel(s) in", feed.Url) println(len(newchannels), "new channel(s) in", feed.Url)
} }

68
testdata/ignoredLink.rss vendored Normal file
View File

@ -0,0 +1,68 @@
<rss version="2.0">
<channel>
<title>Conservatives.com News</title>
<link>http://www.conservatives.com/XMLGateway/RSS/News.xml</link>
<description>Conservatives.com news headlines (RSS 2.0)</description>
<language>en-gb</language>
<item>
<title>Dr Tania Mathias chosen to stand up for local people in Twickenham</title>
<link>http://www.conservatives.com/News/News_stories/2013/09/Dr_Tania_Mathias_chosen_to_stand_up_for_local_people_in_Twickenham.aspx</link>
<description>Last night local residents of Twickenham attended an Open Primary and selected local Twickenham councilor Dr Tania Mathias to be their Conservative candidate for the Twickenham Constituency at the General Election in 2015.</description>
<pubDate>Fri, 06 Sep 2013 17:07:00 GMT</pubDate>
</item>
<item>
<title>Cabinet Ministers warn of Labour tax bombshell on family holidays</title>
<link>http://www.conservatives.com/News/News_stories/2013/08/Cabinet_Ministers_warn_of_Labour_tax_bombshell_on_family_holidays.aspx</link>
<description>Labour want new taxes on local hotels and B and Bs say Maria Miller and Eric Pickles</description>
<pubDate>Fri, 23 Aug 2013 11:52:00 GMT</pubDate>
</item>
<item>
<title>Results of MEP ballot announced</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Conservatives_announce_results_of_MEP_ballot.aspx</link>
<description>Over the last month, Conservative members have been balloted to choose the candidates and their position on the ballot paper for next years European Elections.</description>
<pubDate>Wed, 31 Jul 2013 15:44:00 GMT</pubDate>
</item>
<item>
<title>Marcus Fysh selected for Yeovil</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Marcus_Fysh_selected_for_Yeovil.aspx</link>
<description>Marcus Fysh chosen to stand up for local people in Yeovil</description>
<pubDate>Wed, 31 Jul 2013 14:13:00 GMT</pubDate>
</item>
<item>
<title>Clarence Mitchell selected for Brighton Pavilion</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Clarence_Mitchell_selected_for_Brighton_and_Hove.aspx</link>
<description>Brighton and Hove Conservatives have selected Clarence Mitchell as their Prospective Parliamentary Candidate for Brighton Pavilion in the 2015 General Election.</description>
<pubDate>Tue, 30 Jul 2013 11:14:00 GMT</pubDate>
</item>
<item>
<title>Ann Myatt selected for Westmorland and Lonsdale</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Ann_Myatt_selected_for_Westmorland_and_Lonsdale.aspx</link>
<description>Westmorland and Lonsdale Conservatives have selected Ann Myatt as their Prospective Parliamentary candidate for the 2015 General Election.</description>
<pubDate>Mon, 29 Jul 2013 11:20:00 GMT</pubDate>
</item>
<item>
<title>Robert Alden selected for Birmingham Erdington</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Robert_Alden_selected_for_Birmingham_Erdington.aspx</link>
<description>Erdington Conservative Association is delighted to announce that popular local resident Cllr Robert Alden has been selected to stand at the next general election.</description>
<pubDate>Mon, 29 Jul 2013 10:52:00 GMT</pubDate>
</item>
<item>
<title>Matthew Maxwell Scott selected for Carshalton &amp; Wallington</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Matthew_Maxwell_Scott_selected_for_Carshalton_Wallington.aspx</link>
<description>Carshalton and Wallington Conservatives have selected Matthew Maxwell Scott as their Prospective Parliamentary Candidate for the 2015 General Election. </description>
<pubDate>Fri, 19 Jul 2013 15:14:00 GMT</pubDate>
</item>
<item>
<title>Crime fallen by 10% under this government</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Crime_fallen_by_10_under_this_government.aspx</link>
<description>Recorded crime is down by more than ten per cent under this government, and the independent survey shows that the publics experience of crime is at its lowest level since records began.</description>
<pubDate>Thu, 18 Jul 2013 16:42:00 GMT</pubDate>
</item>
<item>
<title>Unemployment down by 57k in last quarter</title>
<link>http://www.conservatives.com/News/News_stories/2013/07/Unemployment_down_by_57k_in_last_quarter.aspx</link>
<description>Unemployment is down and fewer people are claiming Jobseeker's Allowance than in May 2010</description>
<pubDate>Wed, 17 Jul 2013 10:04:00 GMT</pubDate>
</item>
</channel>
</rss>