beego 测试用例失败路径不对解决方法
网上搜索出来的方案:
修改源码
func TestBeegoInit(ap string) { /* path := filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) InitBeegoBeforeTest(path) */ os.Setenv("BEEGO_RUNMODE", "test") appConfigPath = filepath.Join(ap, "conf", "app.conf") os.Chdir(ap) initBeforeHTTPRun() }
后来 干脆不用beego的配置文件 自己写配置文件自己配置,这样自己可以方便的控制,例如:
func initBeego(c conf.BeegoConfig) { beego.BConfig.RunMode = c.RunMode beego.BConfig.Listen.HTTPAddr = c.HTTPAddr beego.BConfig.Listen.HTTPPort = c.HTTPPort beego.BConfig.RunMode = c.RunMode beego.BConfig.WebConfig.AutoRender = c.AutoRender beego.BConfig.CopyRequestBody = true beego.BConfig.ServerName = "IceServer" }