diff options
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() + } +} |