-
Notifications
You must be signed in to change notification settings - Fork 6
/
cfg_test.go
48 lines (39 loc) · 1 KB
/
cfg_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
package grid
import (
"testing"
"time"
)
func TestSetClientCfgDefaults(t *testing.T) {
t.Parallel()
cfg := ClientCfg{Namespace: "testing"}
if cfg.Timeout != 0 {
t.Fatalf("initial Timeout should be zero value")
}
if cfg.PeersRefreshInterval != 0 {
t.Fatalf("initial PeersRefreshInterval should be zero value")
}
setClientCfgDefaults(&cfg)
if cfg.Timeout != 10*time.Second {
t.Fatalf("initial Timeout should be 10s")
}
if cfg.PeersRefreshInterval != 2*time.Second {
t.Fatalf("initial PeersRefreshInterval should be 2s")
}
}
func TestSetServerCfgDefaults(t *testing.T) {
t.Parallel()
cfg := ServerCfg{Namespace: "testing"}
if cfg.Timeout != 0 {
t.Fatalf("initial Timeout should be zero value")
}
if cfg.LeaseDuration != 0 {
t.Fatalf("initial LeaseDuration should be zero value")
}
setServerCfgDefaults(&cfg)
if cfg.Timeout != 10*time.Second {
t.Fatalf("initial Timeout should be 10s")
}
if cfg.LeaseDuration != 60*time.Second {
t.Fatalf("initial LeaseDuration should be 60s")
}
}