-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
config_test.go
94 lines (83 loc) · 1.5 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package speed
import (
"os"
"testing"
)
func TestRootPath(t *testing.T) {
if rootPath == "" {
t.Errorf("RootPath is invalid")
return
}
_, err := os.Stat(rootPath)
if err != nil {
t.Errorf("RootPath err: %s", err)
}
}
func TestConfPath(t *testing.T) {
if confPath == "" {
t.Errorf("ConfPath is invalid")
return
}
fi, err := os.Stat(confPath)
if err != nil {
return
}
if !fi.Mode().IsRegular() {
t.Errorf("%s should be a regular file", confPath)
return
}
}
var keysToTest = []string{
"PCP_VERSION",
"PCP_USER",
"PCP_GROUP",
"PCP_PLATFORM",
"PCP_PLATFORM_PATHS",
"PCP_ETC_DIR",
"PCP_SYSCONF_DIR",
"PCP_SYSCONFIG_DIR",
"PCP_RC_DIR",
"PCP_BIN_DIR",
"PCP_BINADM_DIR",
"PCP_LIB_DIR",
"PCP_LIB32_DIR",
"PCP_SHARE_DIR",
"PCP_INC_DIR",
"PCP_MAN_DIR",
"PCP_PMCDCONF_PATH",
"PCP_PMCDOPTIONS_PATH",
"PCP_PMCDRCLOCAL_PATH",
"PCP_PMPROXYOPTIONS_PATH",
"PCP_PMIECONTROL_PATH",
"PCP_PMSNAPCONTROL_PATH",
"PCP_PMLOGGERCONTROL_PATH",
"PCP_PMDAS_DIR",
"PCP_RUN_DIR",
"PCP_PMDAS_DIR",
"PCP_LOG_DIR",
"PCP_TMP_DIR",
"PCP_TMPFILE_DIR",
"PCP_DOC_DIR",
"PCP_DEMOS_DIR",
}
var optionalKeysToTest = []string{
"PCP_PMWEBDOPTIONS_PATH",
"PCP_PMMGROPTIONS_PATH",
}
func TestConfig(t *testing.T) {
if config == nil {
return
}
for _, key := range keysToTest {
_, ok := config[key]
if !ok {
t.Errorf("key %s not present in Config", key)
}
}
for _, key := range optionalKeysToTest {
_, ok := config[key]
if !ok {
t.Logf("key %s not present in Config (optional)", key)
}
}
}