-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
61 lines (59 loc) · 1.4 KB
/
config_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
package main
import (
"fmt"
"reflect"
"testing"
)
func TestLoadConfig(t *testing.T) {
cases := map[string]Config{
"empty.yaml": {},
"all-providers.yaml": {
Feeds: []Feed{"example.com/feed.xml"},
Outputs: []Output{
{
Kind: "s3",
Config: map[string]string{
"endpoint": "https://s3.example.com",
"region": "test-region",
"accesskeyid": "test-key",
"accesssecret": "test-secret",
"bucket": "test-bucket",
"keyformat": "{{ .PublishedParsed.UTC.Year }}/{{ .PublishedParsed.UTC.Month }}/{{ .PublishedParsed.UTC.Day }}",
},
},
{
Kind: "file",
Config: map[string]string{
"pathformat": "./data/{{ .PublishedParsed.UTC.Year }}/{{ .PublishedParsed.UTC.Month }}/{{ .PublishedParsed.UTC.Day }}",
},
},
{
Kind: "kafka",
Config: map[string]string{
"broker": "127.0.0.1:9092",
"topic": "feeds",
},
},
{
Kind: "discord",
Config: map[string]string{
"url": "https://discord.example.com/webhook",
},
},
},
Redis: RedisConfig{
Host: "127.0.0.1:6379",
},
},
}
for file, expected := range cases {
t.Run(file, func(t *testing.T) {
t.Parallel()
filename := fmt.Sprintf("testdata/%s", file)
config := loadConfig(filename)
if !reflect.DeepEqual(config, expected) {
t.Errorf("Configs do not match:\n%s\n%s", config, expected)
}
})
}
}