forked from skynetservices/skynet-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_test.go
66 lines (49 loc) · 1.54 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
62
63
64
65
66
package skynet
import (
"os"
"testing"
)
func TestGetServiceConfigFromFlags(t *testing.T) {
os.Args = []string{"test", "--l=localhost:1234", "--region=TestRegion", "--doozer=localhost:8046", "--doozerboot=localhost:1232", "--autodiscover=true"}
config, _ := GetServiceConfigFromFlags()
if config.ServiceAddr.IPAddress != "localhost" {
t.Error("Address not set through flag")
}
if config.ServiceAddr.Port != 1234 {
t.Error("Port not set through flag")
}
if config.Region != "TestRegion" {
t.Error("Region not set through flag")
}
if config.DoozerConfig.Uri != "localhost:8046" {
t.Error("DoozerUri not set through flag")
}
if config.DoozerConfig.BootUri != "localhost:1232" {
t.Error("DoozerBootUri not set through flag")
}
if config.DoozerConfig.AutoDiscover != true {
t.Error("DoozerAutoDiscover not set through flag")
}
}
func TestGetServiceConfigFromFlagsDefaults(t *testing.T) {
os.Args = []string{"test"}
config, _ := GetServiceConfigFromFlags()
if config.ServiceAddr.IPAddress != "127.0.0.1" {
t.Error("Address not set to default value")
}
if config.ServiceAddr.Port != 9999 {
t.Error("Port not set to default value")
}
if config.Region != "unknown" {
t.Error("Region not set to default value")
}
if config.DoozerConfig.Uri != "127.0.0.1:8046" {
t.Error("DoozerUri not set to default value")
}
if config.DoozerConfig.BootUri != "127.0.0.1:8046" {
t.Error("DoozerBootUri not set to default value")
}
if config.DoozerConfig.AutoDiscover != true {
t.Error("DoozerAutoDiscover not set to default value")
}
}