commit
eec8e4f8e6
3 changed files with 3860 additions and 3 deletions
5
rss.go
5
rss.go
|
@ -46,7 +46,7 @@ type Item struct {
|
||||||
Category []string `xml:"category"`
|
Category []string `xml:"category"`
|
||||||
Enclosure []ItemEnclosure `xml:"enclosure"`
|
Enclosure []ItemEnclosure `xml:"enclosure"`
|
||||||
Description string `xml:"description"`
|
Description string `xml:"description"`
|
||||||
Author string `xml:"author"`
|
Author string `xml:"author"`
|
||||||
Content string `xml:"content"`
|
Content string `xml:"content"`
|
||||||
FullText string `xml:"full-text"`
|
FullText string `xml:"full-text"`
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,9 @@ func (d Date) Parse() (time.Time, error) {
|
||||||
t, err := d.ParseWithFormat(wordpressDateFormat)
|
t, err := d.ParseWithFormat(wordpressDateFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t, err = d.ParseWithFormat(time.RFC822) // RSS 2.0 spec
|
t, err = d.ParseWithFormat(time.RFC822) // RSS 2.0 spec
|
||||||
|
if err != nil {
|
||||||
|
t, err = d.ParseWithFormat(time.RFC3339) // Atom
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return t, err
|
return t, err
|
||||||
}
|
}
|
||||||
|
|
10
rss_test.go
10
rss_test.go
|
@ -30,7 +30,7 @@ func (f *testFetcher) Get(url string) (resp *http.Response, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// A trivial test making sure that that all feeds parse - it *does not* check
|
// A trivial test making sure that that all feeds parse - it *does not* check
|
||||||
// for correctness or completeness thereof.
|
// for correctness or completeness thereof, except for dates.
|
||||||
func TestAllFeedsParse(t *testing.T) {
|
func TestAllFeedsParse(t *testing.T) {
|
||||||
fileInfos, err := ioutil.ReadDir(testDataDir)
|
fileInfos, err := ioutil.ReadDir(testDataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -41,8 +41,14 @@ func TestAllFeedsParse(t *testing.T) {
|
||||||
if !strings.HasSuffix(fileName, testFileSuffix) {
|
if !strings.HasSuffix(fileName, testFileSuffix) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if _, err := ReadWithClient(fileName, new(testFetcher)); err != nil {
|
channel, err := ReadWithClient(fileName, new(testFetcher))
|
||||||
|
if err != nil {
|
||||||
t.Fatalf("ReadWithClient(%q) err = %v, expected nil", fileName, err)
|
t.Fatalf("ReadWithClient(%q) err = %v, expected nil", fileName, err)
|
||||||
}
|
}
|
||||||
|
for _, item := range channel.Item {
|
||||||
|
if _, err := item.PubDate.Parse(); err != nil {
|
||||||
|
t.Fatalf("Date Parser(%q) err = %v, expected nil", fileName, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3848
testdata/remoteok.io.rss
vendored
Normal file
3848
testdata/remoteok.io.rss
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue