...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package config
17
18 import (
19 "testing"
20
21 "github.com/kelseyhightower/envconfig"
22 )
23
24 func TestChaosDashboardConfig(t *testing.T) {
25 config := ChaosDashboardConfig{}
26 err := envconfig.Process("", &config)
27 if err != nil {
28 t.Fatal("Error parsing empty ChaosDashboardConfig", err)
29 }
30
31 if config.ListenHost != "0.0.0.0" {
32 t.Error("ListenHost is not set")
33 }
34
35 if config.ListenPort != 2333 {
36 t.Error("ListenPort is not set")
37 }
38
39 if config.ClusterScoped != true {
40 t.Error("ClusterScoped is not set")
41 }
42
43 if config.EnableFilterNamespace != false {
44 t.Error("EnableFilterNamespace is not set")
45 }
46
47 if config.SecurityMode != true {
48 t.Error("SecurityMode is not set")
49 }
50
51 if config.DNSServerCreate != true {
52 t.Error("DNSServerCreate is not set")
53 }
54 }
55
56 func TestTTLConfigWithStringTime(t *testing.T) {
57 config := TTLConfigWithStringTime{}
58 err := envconfig.Process("", &config)
59 if err != nil {
60 t.Fatal("Error parsing empty TTLConfigWithStringTime", err)
61 }
62
63 if config.ResyncPeriod != "12h" {
64 t.Error("ResyncPeriod is not set")
65 }
66
67 if config.EventTTL != "168h" {
68 t.Error("EventTTL is not set")
69 }
70
71 if config.ExperimentTTL != "336h" {
72 t.Error("ExperimentTTL is not set")
73 }
74
75 if config.ScheduleTTL != "336h" {
76 t.Error("ScheduleTTL is not set")
77 }
78
79 if config.WorkflowTTL != "336h" {
80 t.Error("WorkflowTTL is not set")
81 }
82
83 parsed, err := config.Parse()
84
85 if err != nil {
86 t.Fatal("Error parsing config", err)
87 }
88
89 if parsed.ResyncPeriod.Hours() != 12 {
90 t.Errorf("ResyncPeriod is not 12h, but %v", parsed.ResyncPeriod)
91 }
92
93 if parsed.EventTTL.Hours() != 168 {
94 t.Errorf("EventTTL is not 168h, but %v", parsed.EventTTL)
95 }
96
97 if parsed.ExperimentTTL.Hours() != 336 {
98 t.Errorf("ExperimentTTL is not 336h, but %v", parsed.ExperimentTTL)
99 }
100
101 if parsed.ScheduleTTL.Hours() != 336 {
102 t.Errorf("ScheduleTTL is not 336h, but %v", parsed.ScheduleTTL)
103 }
104
105 if parsed.WorkflowTTL.Hours() != 336 {
106 t.Errorf("WorkflowTTL is not 336h, but %v", parsed.WorkflowTTL)
107 }
108 }
109