-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrssparse_test.go
More file actions
63 lines (57 loc) · 1.56 KB
/
rssparse_test.go
File metadata and controls
63 lines (57 loc) · 1.56 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"io/ioutil"
"testing"
)
func TestEnclosureUrlsFromRssStringSingleItem(t *testing.T) {
buffer, _ := ioutil.ReadFile("testdata/singleItemValidRss.rss")
enclosure := EnclosureUrlsFromRssString(string(buffer))
if len(enclosure) != 1 {
t.Error("Enclosure count Mismatch")
}
for _, enc := range enclosure {
verifyEnclosureData(enc, t)
}
}
func TestEnclosureUrlsFromRssStringMultiItem(t *testing.T) {
buffer, _ := ioutil.ReadFile("testdata/multiItemValidRss.rss")
enclosure := EnclosureUrlsFromRssString(string(buffer))
if len(enclosure) != 2 {
t.Error("Enclosure count Mismatch")
}
for _, enc := range enclosure {
verifyEnclosureData(enc, t)
}
}
func TestEnclosureUrlsFromRssBytesSingleItem(t *testing.T) {
buffer, _ := ioutil.ReadFile("testdata/singleItemValidRss.rss")
enclosure := EnclosureUrlsFromRssBytes(buffer)
if len(enclosure) != 1 {
t.Error("Enclosure count Mismatch")
}
for _, enc := range enclosure {
verifyEnclosureData(enc, t)
}
}
func TestEnclosureUrlsFromRssBytesMultiItem(t *testing.T) {
buffer, _ := ioutil.ReadFile("testdata/multiItemValidRss.rss")
enclosure := EnclosureUrlsFromRssBytes(buffer)
if len(enclosure) != 2 {
t.Error("Enclosure count Mismatch")
}
for _, enc := range enclosure {
verifyEnclosureData(enc, t)
}
}
//Helper Verify Methods
func verifyEnclosureData(e Enclosure, t *testing.T) {
if e.URL != "RssItemEnclosureUrl" {
t.Error("Url Mismatch")
}
if e.Type != "RssItemEnclosureType" {
t.Error("Type Mismatch")
}
if e.Length != "RssItemEnclosureLength" {
t.Error("Length Mismatch")
}
}