From 3141202051c973777a8eef366c07baaac2325881 Mon Sep 17 00:00:00 2001 From: astaxie Date: Thu, 3 Apr 2014 16:41:44 +0800 Subject: [PATCH] improve the bee --- apiapp.go | 6 ++++++ new.go | 7 +++++++ test.go | 11 +---------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/apiapp.go b/apiapp.go index 8af8d00..1fc68e2 100644 --- a/apiapp.go +++ b/apiapp.go @@ -214,6 +214,12 @@ import ( . "github.com/smartystreets/goconvey/convey" ) +func init() { + _, file, _, _ := runtime.Caller(1) + apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, "../"))) + beego.TestBeegoInit(apppath) +} + // TestGet is a sample to run an endpoint test func TestGet(t *testing.T) { r, _ := http.NewRequest("GET", "/object", nil) diff --git a/new.go b/new.go index 09e7457..ece78ac 100644 --- a/new.go +++ b/new.go @@ -182,6 +182,13 @@ import ( . "github.com/smartystreets/goconvey/convey" ) +func init() { + _, file, _, _ := runtime.Caller(1) + apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, "../"))) + beego.TestBeegoInit(apppath) +} + + // TestMain is a sample to run an endpoint test func TestMain(t *testing.T) { r, _ := http.NewRequest("GET", "/", nil) diff --git a/test.go b/test.go index 08c33bd..c1b1d0c 100644 --- a/test.go +++ b/test.go @@ -63,23 +63,14 @@ func testApp(cmd *Command, args []string) { ColorLog("[ERRO] Fail to parse bee.json[ %s ]\n", err) } var paths []string - paths = safePathAppend(paths, - path.Join(crupath, conf.DirStruct.Controllers), - path.Join(crupath, conf.DirStruct.Models), - path.Join(crupath, "./")) // Current path. - // Because monitor files has some issues, we watch current directory - // and ignore non-go files. - paths = append(paths, conf.DirStruct.Others...) + readAppDirectories(crupath, &paths) NewWatcher(paths, nil) appname = args[0] - Autobuild(nil) for { select { case <-started: runTest() - //Kill() - //os.Exit(0) } } }