-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparser_test.go
More file actions
106 lines (99 loc) · 2.46 KB
/
parser_test.go
File metadata and controls
106 lines (99 loc) · 2.46 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package feedly
import (
"fmt"
"testing"
)
func TestParseMultipleFeeds(t *testing.T) {
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/",
}
type args struct {
urls []string
strategy OnErrorStrategy
}
tests := []struct {
name string
args args
wantRss []FeedRes
wantErr bool
}{
{
name: "TestParseMultipleFeeds",
args: args{
urls: testUrls,
strategy: IGNORE,
},
wantRss: make([]FeedRes, 0),
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := ParseMultipleFeeds(tt.args.urls, tt.args.strategy)
if (err != nil) != tt.wantErr {
t.Errorf("ParseMultipleFeeds() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}
func TestParseFromUrl(t *testing.T) {
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/",
}
type args struct {
url string
}
tests := make([]struct {
name string
args args
wantRss *Rss
wantErr bool
}, 0)
for _, url := range testUrls {
tests = append(tests, struct {
name string
args args
wantRss *Rss
wantErr bool
}{
name: fmt.Sprintf("TestParseFromUrl %s", url),
args: args{
url: url,
},
wantRss: &Rss{},
wantErr: false,
})
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := ParseFromUrl(tt.args.url)
if (err != nil) != tt.wantErr {
t.Errorf("ParseFromUrl() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}