-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfeed_test.go
More file actions
73 lines (66 loc) · 1.57 KB
/
feed_test.go
File metadata and controls
73 lines (66 loc) · 1.57 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
64
65
66
67
68
69
70
71
72
73
package feedly
import (
"reflect"
"testing"
)
func TestNewRSS(t *testing.T) {
c := NewClient()
type args struct {
src []byte
}
tests := make([]struct {
name string
args args
want *Rss
want1 UnMarshallError
}, 0)
testUrls := []string{
"https://www.caranddriver.com/rss/all.xml/",
"https://jalopnik.com/rss",
"https://www.autoblog.com/rss.xml",
"http://feeds.feedburner.com/autonews/AutomakerNews",
"http://feeds.feedburner.com/autonews/SupplierNews",
"http://feeds.feedburner.com/autonews/EuropeNews",
"http://feeds.feedburner.com/MobilityReport",
"http://feeds.feedburner.com/autonews/RetailNews",
"https://www.carthrottle.com/rss/",
"https://feeds.highgearmedia.com/",
"https://www.thetruthaboutcars.com/rss/feed/all",
"https://insideevs.com/rss/articles/all/",
}
for _, url := range testUrls {
t.Run(url, func(t *testing.T) {
code, res, err := c.FetchFeed(url)
if err.error != nil {
t.Errorf("FetchFeed() err = %v", err)
}
if code != 200 {
t.Errorf("FetchFeed() code = %v", code)
}
tests = append(tests, struct {
name string
args args
want *Rss
want1 UnMarshallError
}{
name: url,
args: args{
src: res,
},
want: &Rss{},
want1: UnMarshallError{nil},
})
})
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := NewRSS(tt.args.src)
if got.Channel.Title == "" {
t.Errorf("NewRSS() got = %v, want %v", got, tt.want)
}
if !reflect.DeepEqual(got1, tt.want1) {
t.Errorf("NewRSS() got1 = %v, want %v", got1, tt.want1)
}
})
}
}