diff options
author | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 00:41:55 +0300 |
---|---|---|
committer | Evgeny Kuznetsov <evgeny@kuznetsov.md> | 2020-01-28 00:44:02 +0300 |
commit | 93204ba85cde21c5aa2d5889eddeb5b2e9b7d035 (patch) | |
tree | a91d868289853ea9fe8c9252869c05c5a6e4569a /main_test.go | |
parent | 99bb487fefcba22903aceb63f128886a74efc420 (diff) | |
download | radiorus-rss-93204ba85cde21c5aa2d5889eddeb5b2e9b7d035.tar.gz radiorus-rss-93204ba85cde21c5aa2d5889eddeb5b2e9b7d035.zip |
test feed population
Diffstat (limited to 'main_test.go')
-rw-r--r-- | main_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
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() + } +} |