-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathctrl_test.go
44 lines (40 loc) · 1.07 KB
/
ctrl_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
package main
import (
"github.com/antavelos/terminews/db"
"testing"
)
func TestGetContentURL(t *testing.T) {
type test struct {
site db.Site
url string
expected string
}
tests := []test{
{
site: db.Site{Url: "https://blog.example.org/index.xml"},
url: "/2021/02/a-blog-post",
expected: "https://blog.example.org/2021/02/a-blog-post",
},
{
site: db.Site{Url: "http://blog.example.org/index.xml"},
url: "2021/02/a-blog-post",
expected: "http://blog.example.org/2021/02/a-blog-post",
},
{
site: db.Site{Url: "https://blog.example.org/feed.rss"},
url: "https://blog.example.org/super-blog-post",
expected: "https://blog.example.org/super-blog-post",
},
{
site: db.Site{Url: "http://blog.example.org/feed.rss"},
url: "http://blog.example.org/super-blog-post",
expected: "http://blog.example.org/super-blog-post",
},
}
for _, test := range tests {
value := getContentURL(test.site, test.url)
if value != test.expected {
t.Errorf("got: %s want: %s", value, test.expected)
}
}
}