beego: run mode support test
Showing
2 changed files
with
6 additions
and
1 deletions
| ... | @@ -384,6 +384,7 @@ func initBeforeHttpRun() { | ... | @@ -384,6 +384,7 @@ func initBeforeHttpRun() { |
| 384 | // this function is for test package init | 384 | // this function is for test package init |
| 385 | func TestBeegoInit(apppath string) { | 385 | func TestBeegoInit(apppath string) { |
| 386 | AppPath = apppath | 386 | AppPath = apppath |
| 387 | RunMode = "test" | ||
| 387 | AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") | 388 | AppConfigPath = filepath.Join(AppPath, "conf", "app.conf") |
| 388 | err := ParseConfig() | 389 | err := ParseConfig() |
| 389 | if err != nil && !os.IsNotExist(err) { | 390 | if err != nil && !os.IsNotExist(err) { | ... | ... |
| ... | @@ -178,7 +178,11 @@ func ParseConfig() (err error) { | ... | @@ -178,7 +178,11 @@ func ParseConfig() (err error) { |
| 178 | AppConfig = config.NewFakeConfig() | 178 | AppConfig = config.NewFakeConfig() |
| 179 | return err | 179 | return err |
| 180 | } else { | 180 | } else { |
| 181 | HttpAddr = AppConfig.String("HttpAddr") | 181 | if v := AppConfig.String(RunMode + "::HttpAddr"); v != "" { |
| 182 | HttpAddr = v | ||
| 183 | } else { | ||
| 184 | HttpAddr = AppConfig.String("HttpAddr") | ||
| 185 | } | ||
| 182 | 186 | ||
| 183 | if v, err := AppConfig.Int("HttpPort"); err == nil { | 187 | if v, err := AppConfig.Int("HttpPort"); err == nil { |
| 184 | HttpPort = v | 188 | HttpPort = v | ... | ... |
-
Please register or sign in to post a comment