forked from devfeel/dotweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotweb_test.go
65 lines (56 loc) · 1.47 KB
/
dotweb_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
package dotweb
import (
"fmt"
"github.com/devfeel/dotweb/config"
"github.com/devfeel/dotweb/test"
"testing"
)
// 以下为功能测试
// 测试RunMode函数无配置文件时的返回值
func Test_RunMode_1(t *testing.T) {
app := New()
runMode := app.RunMode()
t.Log("RunMode:", runMode)
}
// 测试RunMode函数有配置文件时的返回值
func Test_RunMode_2(t *testing.T) {
runModes := []string{"dev", "development", "prod", "production"}
app := New()
for _, value := range runModes {
app.Config.App.RunMode = value
runMode := app.RunMode()
t.Log("runModes value:", value, "RunMode:", runMode)
}
}
//测试IsDevelopmentMode函数
func Test_IsDevelopmentMode_1(t *testing.T) {
app := New()
app.Config.App.RunMode = "development"
b := app.IsDevelopmentMode()
test.Equal(t, true, b)
t.Log("Run IsDevelopmentMode :", b)
}
func Test_IsDevelopmentMode_2(t *testing.T) {
app := New()
app.Config.App.RunMode = "production"
b := app.IsDevelopmentMode()
t.Log("Run IsDevelopmentMode :", b)
}
func TestDotWeb_UsePlugin(t *testing.T) {
app := newConfigDotWeb()
app.UsePlugin(new(testPlugin))
app.UsePlugin(NewDefaultNotifyPlugin(app))
fmt.Println(app.pluginMap)
app.StartServer(8081)
}
func newConfigDotWeb() *DotWeb {
app := New()
appConfig, err := config.InitConfig("d:/gotmp/dotweb.conf", "xml")
if err != nil {
fmt.Println("dotweb.InitConfig error => " + fmt.Sprint(err))
return nil
}
app.Logger().SetEnabledConsole(true)
app.SetConfig(appConfig)
return app
}