From 93204ba85cde21c5aa2d5889eddeb5b2e9b7d035 Mon Sep 17 00:00:00 2001 From: Evgeny Kuznetsov Date: Tue, 28 Jan 2020 00:41:55 +0300 Subject: test feed population --- main_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'main_test.go') diff --git a/main_test.go b/main_test.go index 7335c47..cde6e7b 100644 --- a/main_test.go +++ b/main_test.go @@ -21,6 +21,8 @@ import ( "io/ioutil" "path/filepath" "testing" + + "github.com/gorilla/feeds" ) var update = flag.Bool("update", false, "update .golden files") @@ -50,3 +52,27 @@ func TestCleanText(t *testing.T) { t.Fail() } } + +func TestFeed(t *testing.T) { + page := helperLoadBytes(t, "episodes") + page = cleanText(page) + + feed := &feeds.Feed{ + Link: &feeds.Link{Href: "http://www.radiorus.ru/brand/57083/episodes"}, + } + + populateFeed(feed, page) + + actual := createFeed(feed) + golden := filepath.Join("testdata", t.Name()+".golden") + if *update { + if err := ioutil.WriteFile(golden, actual, 0644); err != nil { + t.Fatal(err) + } + } + expected, _ := ioutil.ReadFile(golden) + + if !bytes.Equal(actual, expected) { + t.Fail() + } +} -- cgit v1.2.3