-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
63 lines (58 loc) · 1.38 KB
/
main_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"testing"
)
func TestMain(t *testing.T) {
}
func TestConfigValidation(t *testing.T) {
tests := []struct {
name string
config Config
wantErr bool
}{
{
name: "valid config",
config: Config{
Feeds: []string{"http://example.com/blog.rss", "http://example.org/feed.atom", "https://blog.example.net/feed.xml"},
NotionDBID: "8a994146-f3da-4f92-8a9d-2f993c16d95f",
NotionAPIKey: "b4d4f338-b1c4-4c22-a29c-c5fec9d63c0a",
},
wantErr: false,
},
{
name: "missing feeds",
config: Config{
Feeds: []string{},
NotionDBID: "8a994146-f3da-4f92-8a9d-2f993c16d95f",
NotionAPIKey: "b4d4f338-b1c4-4c22-a29c-c5fec9d63c0a",
},
wantErr: true,
},
{
name: "missing notion db id",
config: Config{
Feeds: []string{"http://example.com/blog.rss"},
NotionDBID: "",
NotionAPIKey: "b4d4f338-b1c4-4c22-a29c-c5fec9d63c0a",
},
wantErr: true,
},
{
name: "missing notion api key",
config: Config{
Feeds: []string{"http://example.com/blog.rss"},
NotionDBID: "8a994146-f3da-4f92-8a9d-2f993c16d95f",
NotionAPIKey: "",
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
err := tt.config.Validate()
if (err != nil) != tt.wantErr {
t.Errorf("Config.Validate() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}