From 587088fc7d93c4e3bb918b97ec2a27f54d6f6db8 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Tue, 4 Feb 2020 17:06:32 +0300 Subject: fix processing page with upcoming announce --- main_test.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go index b744537..1c6363b 100644 --- a/main_test.go +++ b/main_test.go @@ -83,6 +83,56 @@ func TestFeed(t *testing.T) { } } +func TestFindEpisodes(t *testing.T) { + var tests = []string{ + "episodes", + "episodes.59798", + "episodes.63147", + } + + for _, test := range tests { + page := helperLoadBytes(t, test) + page = cleanText(page) + + actual := bytes.Join(findEpisodes(page), []byte("\n&&&\n")) + golden := filepath.Join("testdata", t.Name()+"."+test+".golden") + if *update { + writeFile(actual, golden) + } + expected, _ := ioutil.ReadFile(golden) + + if !bytes.Equal(actual, expected) { + t.Fail() + } + } +} + +func TestUpdatingFeed(t *testing.T) { + var page []byte + + feed := &feeds.Feed{ + Link: &feeds.Link{Href: "http://www.radiorus.ru/brand/59798/episodes"}, + } + + page = helperLoadBytes(t, "episodes.59798") + page = cleanText(page) + + if err := populateFeed(feed, page); err != nil { + t.Fatal(err) + } + + actual := createFeed(feed) + golden := filepath.Join("testdata", t.Name()+".golden") + if *update { + writeFile(actual, golden) + } + expected, _ := ioutil.ReadFile(golden) + + if !bytes.Equal(actual, expected) { + t.Fail() + } +} + func TestVideoFeed(t *testing.T) { var page []byte -- cgit v1.2.3