From a3882284e0078b1c5a7d95b6b7bbaf3ef2f37dc0 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 18 Jan 2014 14:35:00 -0200 Subject: [PATCH] test conservatives feed --- feed_test.go | 20 ++++++++++++ testdata/ignoredLink.rss | 68 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 testdata/ignoredLink.rss diff --git a/feed_test.go b/feed_test.go index dca55b3..5718fca 100644 --- a/feed_test.go +++ b/feed_test.go @@ -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) { println(len(newchannels), "new channel(s) in", feed.Url) } diff --git a/testdata/ignoredLink.rss b/testdata/ignoredLink.rss new file mode 100644 index 0000000..7025a01 --- /dev/null +++ b/testdata/ignoredLink.rss @@ -0,0 +1,68 @@ + + + Conservatives.com News + http://www.conservatives.com/XMLGateway/RSS/News.xml + Conservatives.com news headlines (RSS 2.0) + en-gb + + Dr Tania Mathias chosen to stand up for local people in Twickenham + http://www.conservatives.com/News/News_stories/2013/09/Dr_Tania_Mathias_chosen_to_stand_up_for_local_people_in_Twickenham.aspx + 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. + Fri, 06 Sep 2013 17:07:00 GMT + + + Cabinet Ministers warn of Labour tax bombshell on family holidays + http://www.conservatives.com/News/News_stories/2013/08/Cabinet_Ministers_warn_of_Labour_tax_bombshell_on_family_holidays.aspx + Labour want new taxes on local hotels and B and Bs say Maria Miller and Eric Pickles + Fri, 23 Aug 2013 11:52:00 GMT + + + Results of MEP ballot announced + http://www.conservatives.com/News/News_stories/2013/07/Conservatives_announce_results_of_MEP_ballot.aspx + Over the last month, Conservative members have been balloted to choose the candidates and their position on the ballot paper for next year’s European Elections. + Wed, 31 Jul 2013 15:44:00 GMT + + + Marcus Fysh selected for Yeovil + http://www.conservatives.com/News/News_stories/2013/07/Marcus_Fysh_selected_for_Yeovil.aspx + Marcus Fysh chosen to stand up for local people in Yeovil + Wed, 31 Jul 2013 14:13:00 GMT + + + Clarence Mitchell selected for Brighton Pavilion + http://www.conservatives.com/News/News_stories/2013/07/Clarence_Mitchell_selected_for_Brighton_and_Hove.aspx + Brighton and Hove Conservatives have selected Clarence Mitchell as their Prospective Parliamentary Candidate for Brighton Pavilion in the 2015 General Election. + Tue, 30 Jul 2013 11:14:00 GMT + + + Ann Myatt selected for Westmorland and Lonsdale + http://www.conservatives.com/News/News_stories/2013/07/Ann_Myatt_selected_for_Westmorland_and_Lonsdale.aspx + Westmorland and Lonsdale Conservatives have selected Ann Myatt as their Prospective Parliamentary candidate for the 2015 General Election. + Mon, 29 Jul 2013 11:20:00 GMT + + + Robert Alden selected for Birmingham Erdington + http://www.conservatives.com/News/News_stories/2013/07/Robert_Alden_selected_for_Birmingham_Erdington.aspx + Erdington Conservative Association is delighted to announce that popular local resident Cllr Robert Alden has been selected to stand at the next general election. + Mon, 29 Jul 2013 10:52:00 GMT + + + Matthew Maxwell Scott selected for Carshalton & Wallington + http://www.conservatives.com/News/News_stories/2013/07/Matthew_Maxwell_Scott_selected_for_Carshalton_Wallington.aspx + Carshalton and Wallington Conservatives have selected Matthew Maxwell Scott as their Prospective Parliamentary Candidate for the 2015 General Election. + Fri, 19 Jul 2013 15:14:00 GMT + + + Crime fallen by 10% under this government + http://www.conservatives.com/News/News_stories/2013/07/Crime_fallen_by_10_under_this_government.aspx + Recorded crime is down by more than ten per cent under this government, and the independent survey shows that the public’s experience of crime is at its lowest level since records began. + Thu, 18 Jul 2013 16:42:00 GMT + + + Unemployment down by 57k in last quarter + http://www.conservatives.com/News/News_stories/2013/07/Unemployment_down_by_57k_in_last_quarter.aspx + Unemployment is down and fewer people are claiming Jobseeker's Allowance than in May 2010 + Wed, 17 Jul 2013 10:04:00 GMT + + +