diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-11-26 07:49:26 -0500 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-11-26 07:49:26 -0500 |
commit | f06da1815748cbad110e817097c7bc14e32b1055 (patch) | |
tree | 36ca13efb99d63fe1291ed40e209c947b94e8fa3 /feed/feed_test.go | |
parent | fac1158a67ce41809a69feb76c88bfae0a0b4bfa (diff) |
feed: add `podcastUnmarshal`
Diffstat (limited to 'feed/feed_test.go')
-rw-r--r-- | feed/feed_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/feed/feed_test.go b/feed/feed_test.go new file mode 100644 index 0000000..8f566e6 --- /dev/null +++ b/feed/feed_test.go @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: ISC +// Copyright © 2022 siddharth <s@ricketyspace.net> + +package feed + +import ( + "net/url" + "testing" + + "ricketyspace.net/fern/file" +) + +func TestPodcastUnmarshal(t *testing.T) { + testFeeds := []string{ + "testdata/pc-atp.xml", + "testdata/pc-daringfireball.xml", + "testdata/pc-kara.xml", + "testdata/pc-scwpod.xml", + } + for _, feed := range testFeeds { + bs, err := file.ReadFile(feed) + if err != nil { + t.Errorf("read feed: %v", err) + return + } + entries, err := podcastUnmarshal(bs) + if err != nil { + t.Errorf("feed unmarshal: %v", err) + return + } + for _, entry := range entries { + if len(entry.Id) < 1 { + t.Errorf("entry id: %v", entry.Id) + return + } + if len(entry.Title) < 1 { + t.Errorf("entry title: %v", entry.Title) + return + } + if entry.PubTime.Unix() < 994702392 { + t.Errorf("entry time: %v", entry.PubTime) + return + } + _, err = url.Parse(entry.Link) + if err != nil { + t.Errorf("entry link: %s: %v", entry.Link, err) + return + } + } + } +} |