From 789eb9f24ac72505ef8bd89d6c94a99ba9d7efad Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Wed, 5 Feb 2020 19:51:43 +0300 Subject: parse episodes more safely --- main_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go index 2d520cb..d00a6ae 100644 --- a/main_test.go +++ b/main_test.go @@ -27,6 +27,7 @@ import ( "os/exec" "path/filepath" "regexp" + "strconv" "strings" "sync" "testing" @@ -91,6 +92,21 @@ func TestFeed(t *testing.T) { assertGolden(t, actual, golden) } +func TestBadEpisode(t *testing.T) { + feed := &feeds.Feed{ + Link: &feeds.Link{Href: "http://www.radiorus.ru/brand/57083/episodes"}, + } + + for i := 0; i <= 1; i++ { + page := helperLoadBytes(t, "episodes.badep."+strconv.Itoa(i)) + page = cleanText(page) + + if err := populateFeed(feed, page); err != errBadEpisode { + t.Error("for sample", i, "want:", errBadEpisode, "got:", err) + } + } +} + func TestFindEpisodes(t *testing.T) { var tests = []string{ "episodes", -- cgit v1.2.3