diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-04 17:06:32 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-02-04 17:06:32 +0300 |
commit | 587088fc7d93c4e3bb918b97ec2a27f54d6f6db8 (patch) | |
tree | c78f74a4eec9966742c58b2db523e111c22dfc35 /main_test.go | |
parent | 743db103e2b9810822805129fb1241d55499b134 (diff) | |
download | radiorus-rss-587088fc7d93c4e3bb918b97ec2a27f54d6f6db8.tar.gz radiorus-rss-587088fc7d93c4e3bb918b97ec2a27f54d6f6db8.zip |
fix processing page with upcoming announce
Diffstat (limited to 'main_test.go')
-rw-r--r-- | main_test.go | 50 |
1 files changed, 50 insertions, 0 deletions
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 |