/
poo_test.go
45 lines (41 loc) · 861 Bytes
/
poo_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
35
36
37
38
39
40
41
42
43
44
45
package poo_test
import (
"fmt"
"github.com/gr4y/poo"
"io/ioutil"
"testing"
)
func TestWithURL(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
feed, err := poo.ParseFeed("http://blog.swessel.me/feed")
if err != nil {
t.Error(err)
}
if feed.Channel.Title != "gr4ys blog" {
t.Log(feed.Channel.Title)
t.Fail()
}
}
func TestWithString(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
xmlFeed := readXML("feeds/example-itunes_feed.xml")
feed, err := poo.ParseXML(xmlFeed)
if err != nil {
t.Error(err)
}
if feed.Channel.Title != "All About Everything" {
t.Log(fmt.Sprintf("%s doesn't match", feed.Channel.Title))
t.Fail()
}
}
func readXML(filename string) string {
bytes, err := ioutil.ReadFile(filename)
if err != nil {
fmt.Println(err)
}
return string(bytes)
}