Adding copied tests
This commit is contained in:
parent
656014ea71
commit
728ac72dff
19
tests/main.go
Normal file
19
tests/main.go
Normal file
@ -0,0 +1,19 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
_ "multitenantStack/routers"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/astaxie/beego/orm"
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func init() {
|
||||
orm.RegisterDataBase("default", "postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre sslmode=disable")
|
||||
orm.RegisterDataBase("company1", "postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company1 sslmode=disable")
|
||||
orm.RegisterDataBase("company2", "postgres", "host=127.0.0.1 port=5435 user=postgres password=postgre dbname=company2 sslmode=disable")
|
||||
|
||||
orm.Debug = true
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
|
||||
}
|
41
tests/main_test.go
Normal file
41
tests/main_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func init() {
|
||||
_, file, _, _ := runtime.Caller(0)
|
||||
apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
|
||||
|
||||
beego.TestBeegoInit(apppath)
|
||||
fmt.Println(apppath)
|
||||
}
|
||||
|
||||
// TestBeego is a sample to run an endpoint test
|
||||
func TestBeego(t *testing.T) {
|
||||
time.Sleep(1000)
|
||||
r, _ := http.NewRequest("GET", "/v1/posts", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
beego.BeeApp.Handlers.ServeHTTP(w, r)
|
||||
beego.Trace("testing", "TestBeego", "Code [ %d ]\n%s", w.Code, w.Body.String())
|
||||
|
||||
Convey("Subject: Test Station Endpoint\n", t, func() {
|
||||
Convey("Status Code Should Be 200", func() {
|
||||
So(w.Code, ShouldEqual, 200)
|
||||
})
|
||||
Convey("The Result Should Not Be Empty", func() {
|
||||
So(w.Body.Len(), ShouldBeGreaterThan, 0)
|
||||
})
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user