2017-01-26 15:39:06 +00:00
|
|
|
package changelog
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestFeed(t *testing.T) {
|
2017-02-27 13:57:04 +00:00
|
|
|
fh, err := os.Open("testdata/slackware64/ChangeLog.txt")
|
2017-01-26 15:39:06 +00:00
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
defer fh.Close()
|
|
|
|
|
|
|
|
e, err := Parse(fh)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := ToFeed("http://slackware.osuosl.org/slackware64-current/ChangeLog.txt", e)
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
rss, err := f.ToRss()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
//println(rss)
|
|
|
|
if len(rss) == 0 {
|
|
|
|
t.Error("rss output is empty")
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := f.WriteRss(ioutil.Discard); err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
|
|
|
}
|