From 49e91ffeee298b0655d148389bc4c7f32e8fc7a7 Mon Sep 17 00:00:00 2001 From: Harm Aarts Date: Thu, 5 Dec 2013 16:29:55 +0100 Subject: [PATCH] Adds test for the new items --- feed_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/feed_test.go b/feed_test.go index 60bad51..dca55b3 100644 --- a/feed_test.go +++ b/feed_test.go @@ -29,6 +29,26 @@ func TestFeed(t *testing.T) { } } +func Test_NewItem(t *testing.T) { + content, _ := ioutil.ReadFile("testdata/initial.atom") + feed := New(1, true, chanHandler, itemHandler) + err := feed.FetchBytes("http://example.com", content, nil) + if err != nil { + t.Error(err) + } + + content, _ = ioutil.ReadFile("testdata/initial_plus_one_new.atom") + feed.FetchBytes("http://example.com", content, nil) + expected := "Second title" + if len(items) != 1 { + t.Errorf("Expected %s new item, got %s", 1, len(items)) + } + + if expected != items[0].Title { + t.Errorf("Expected %s, got %s", expected, items[0].Title) + } +} + func Test_AtomAuthor(t *testing.T) { content, err := ioutil.ReadFile("testdata/idownload.atom") if err != nil {