summaryrefslogtreecommitdiffstats
path: root/feed/feed_test.go
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-11-26 07:59:01 -0500
committersiddharth ravikumar <s@ricketyspace.net>2022-11-26 07:59:01 -0500
commitda88db4a6b8783cbe5f52b5e9cc1ae6a270b2401 (patch)
treed013f917eb8b27ba580c37ea3ae5c2c9b62d2506 /feed/feed_test.go
parent3d778ffcc315dca48ea959668528c05db7345eaf (diff)
feed: update `Feed.unmarshal`
Add handling to unmarshal 'podcast' feeds.
Diffstat (limited to 'feed/feed_test.go')
-rw-r--r--feed/feed_test.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/feed/feed_test.go b/feed/feed_test.go
index 7b38ae8..c700a71 100644
--- a/feed/feed_test.go
+++ b/feed/feed_test.go
@@ -49,3 +49,41 @@ func TestPodcastUnmarshal(t *testing.T) {
}
}
}
+
+func TestUnmarshal(t *testing.T) {
+ testFeeds := map[string]string{
+ "podcast": "testdata/pc-daringfireball.xml",
+ }
+ for schema, feed := range testFeeds {
+ bs, err := file.ReadFile(feed)
+ if err != nil {
+ t.Errorf("read feed: %v", err)
+ return
+ }
+ feed := new(Feed)
+ feed.Schema = schema
+ if err = feed.unmarshal(bs); err != nil {
+ t.Errorf("feed unmarshal: %v", err)
+ return
+ }
+ for _, entry := range feed.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
+ }
+ }
+ }
+}