-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
55 lines (43 loc) · 1.22 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
package main
import (
"log"
"testing"
yaml "gopkg.in/yaml.v2"
)
var testdata = `interval: 1m
delete_destination_rules: true
source:
aws_access_key_id: ACCESSKEY
aws_secret_access_key: SECRETKEY
region: eu-central-1
group_id: sg-1
destinations:
-
aws_access_key_id: ACCESSKEY1
aws_secret_access_key: SECRETKEY1
region: us-west-1
group_ids: ["sg-1","sg-2"]
-
aws_access_key_id: ACCESSKEY2
aws_secret_access_key: SECRETKEY2
region: eu-east-1
group_ids: ["sg-1","sg-2","sg-3"]`
func Test_ParseConfig(t *testing.T) {
cfg := SyncConfig{}
err := yaml.Unmarshal([]byte(testdata), &cfg)
if err != nil {
log.Fatalf("error: %v", err)
}
if cfg.Interval != "1m" {
t.Errorf("interval value not expected got: %s, want: %s", cfg.Interval, "1m")
}
if cfg.Source.AWSAccessKeyID == "ACCESSKEY1" {
t.Errorf("source accesskeyid not expected got: %s, want: %s", cfg.Source.AWSAccessKeyID, "ACCESSKEY1")
}
if len(cfg.Destinations) != 2 {
t.Errorf("destinations array size not expected got: %d, want: %d", len(cfg.Destinations), 2)
}
if len(cfg.Destinations[1].GroupIDs) != 3 {
t.Errorf("destinations group array size not expected got: %d, want: %d", len(cfg.Destinations[1].GroupIDs), 3)
}
}