31 lines
519 B
Go
31 lines
519 B
Go
|
package rss
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"path/filepath"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestParseRSS(t *testing.T) {
|
||
|
tests := map[string]string{
|
||
|
"rss_1.0": "Golem.de",
|
||
|
}
|
||
|
|
||
|
for test, want := range tests {
|
||
|
name := filepath.Join("testdata", test)
|
||
|
data, err := ioutil.ReadFile(name)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Reading %s: %v", name, err)
|
||
|
}
|
||
|
|
||
|
feed, err := Parse(data)
|
||
|
if err != nil {
|
||
|
t.Fatalf("Parsing %s: %v", name, err)
|
||
|
}
|
||
|
|
||
|
if feed.Title != want {
|
||
|
t.Errorf("%s: got %q, want %q", name, feed.Title, want)
|
||
|
}
|
||
|
}
|
||
|
}
|