summaryrefslogtreecommitdiffstats
path: root/schema/schema_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'schema/schema_test.go')
-rw-r--r--schema/schema_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/schema/schema_test.go b/schema/schema_test.go
index b80ad3f..aee2452 100644
--- a/schema/schema_test.go
+++ b/schema/schema_test.go
@@ -66,3 +66,51 @@ func TestPodcastFeed(t *testing.T) {
}
}
}
+
+func TestYoutubeFeed(t *testing.T) {
+ var testFeeds = []string{
+ "testdata/yt-mkbhd.xml",
+ }
+ for _, feed := range testFeeds {
+ var bs, err = file.ReadFile(feed)
+ if err != nil {
+ t.Errorf("read feed: %v", err)
+ return
+ }
+ var yf = new(YouTubeFeed)
+ err = xml.Unmarshal(bs, yf)
+ if err != nil {
+ t.Errorf("xml unmarshal: %v", err)
+ return
+ }
+ for _, entry := range yf.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 len(entry.Desc) < 1 {
+ t.Errorf("entry desc: %v", entry.Desc)
+ return
+ }
+ var pt, err = time.Parse(time.RFC3339, entry.Pub)
+ if err != nil {
+ t.Errorf("entry pub: %v: '%v'", time.RFC3339, entry.Pub)
+ return
+ }
+ if pt.Unix() < 994702392 {
+ t.Errorf("entry time: %v", pt)
+ return
+ }
+ _, err = url.Parse(entry.Link.Url)
+ if err != nil {
+ t.Errorf("entry link: %v", err)
+ return
+ }
+ }
+ }
+}
+