-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
45 lines (39 loc) · 1.18 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
package utils
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/ungerik/go-dry"
"net"
"runtime"
"testing"
"wingao.net/webproj/core"
)
func TestMConfig_Get(t *testing.T) {
conf, err := core.NewConfigFromFile(dry.GetenvDefault("WING_GO_CONF", ""))
assert.NoError(t, err)
islocal := conf.Get("islocal")
assert.Equal(t, true, islocal)
}
func TestMConfig_GetString(t *testing.T) {
conf, err := core.NewConfigFromFile(dry.GetenvDefault("WING_GO_CONF", ""))
assert.NoError(t, err)
s := conf.GetString("test.a", "")
assert.Equal(t, "a123", s)
s = conf.GetString("testadminsession", "")
assert.Equal(t, "d7e3c712-15ad-4935-a7c9-6d4fc1719fee", s)
}
func TestMConfig_AbsPath(t *testing.T) {
conf, err := core.NewConfigFromFile(dry.GetenvDefault("WING_GO_CONF", ""))
assert.NoError(t, err)
t.Log(conf.configPath)
t.Log(conf.AbsPath("../helloAbs"))
}
func TestMConfig_Addr(t *testing.T) {
conf, _ := core.NewConfigFromFile(dry.GetenvDefault("WING_GO_CONF", ""))
addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("%s:%s", conf.Host, conf.Port))
assert.Equal(t, 7031, addr.Port)
}
func TestLoadForTest(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
fmt.Println(filename)
}