-
Notifications
You must be signed in to change notification settings - Fork 68
/
feed_test.go
34 lines (27 loc) · 880 Bytes
/
feed_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package feeder
import "testing"
import "os"
func TestFeed(t *testing.T) {
urilist := []string{
//"http://store.steampowered.com/feeds/news.xml", // This feed violates the rss spec.
"http://cyber.law.harvard.edu/rss/examples/sampleRss091.xml",
"http://cyber.law.harvard.edu/rss/examples/sampleRss092.xml",
"http://cyber.law.harvard.edu/rss/examples/rss2sample.xml",
"http://blog.case.edu/news/feed.atom",
}
var feed *Feed
var err os.Error
for _, uri := range urilist {
feed = New(5, true, chanHandler, itemHandler)
if err = feed.Fetch(uri); err != nil {
t.Errorf("%s >>> %s", uri, err)
return
}
}
}
func chanHandler(feed *Feed, newchannels []*Channel) {
println(len(newchannels), "new channel(s) in", feed.Url)
}
func itemHandler(feed *Feed, ch *Channel, newitems []*Item) {
println(len(newitems), "new item(s) in", ch.Title, "of", feed.Url)
}