Fixed packages in tests

This commit is contained in:
Deluan 2016-02-25 11:14:16 -05:00
parent d3542c48e4
commit 77e01f8e7c
5 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
package test package controller_test
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package test package controller_test
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package test package controller_test
import ( import (
"testing" "testing"

View File

@ -1,4 +1,4 @@
package test package controller_test
import ( import (
"testing" "testing"
@ -12,7 +12,7 @@ import (
func TestCheckParams(t *testing.T) { func TestCheckParams(t *testing.T) {
_, w := Get("/rest/ping.view", "TestCheckParams") _, w := Get("/rest/ping.view", "TestCheckParams")
Convey("Subject: Validation\n", t, func() { Convey("Subject: CheckParams\n", t, func() {
Convey("Status code should be 200", func() { Convey("Status code should be 200", func() {
So(w.Code, ShouldEqual, 200) So(w.Code, ShouldEqual, 200)
}) })
@ -30,7 +30,7 @@ func TestCheckParams(t *testing.T) {
func TestAuthentication(t *testing.T) { func TestAuthentication(t *testing.T) {
_, w := Get("/rest/ping.view?u=INVALID&p=INVALID&c=test&v=1.0.0", "TestAuthentication") _, w := Get("/rest/ping.view?u=INVALID&p=INVALID&c=test&v=1.0.0", "TestAuthentication")
Convey("Subject: Validation\n", t, func() { Convey("Subject: Authentication\n", t, func() {
Convey("Status code should be 200", func() { Convey("Status code should be 200", func() {
So(w.Code, ShouldEqual, 200) So(w.Code, ShouldEqual, 200)
}) })

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"path/filepath" "path/filepath"
"runtime" "runtime"
"os"
) )
const ( const (
@ -20,6 +21,11 @@ func init() {
_, file, _, _ := runtime.Caller(1) _, file, _, _ := runtime.Caller(1)
appPath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator)))) appPath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".." + string(filepath.Separator))))
beego.TestBeegoInit(appPath) beego.TestBeegoInit(appPath)
noLog := os.Getenv("NOLOG")
if noLog != "" {
beego.SetLevel(beego.LevelError)
}
} }
func AddParams(url string) string { func AddParams(url string) string {
@ -31,7 +37,7 @@ func Get(url string, testCase string) (*http.Request, *httptest.ResponseRecorder
w := httptest.NewRecorder() w := httptest.NewRecorder()
beego.BeeApp.Handlers.ServeHTTP(w, r) beego.BeeApp.Handlers.ServeHTTP(w, r)
beego.Trace("testing", testCase, fmt.Sprintf("\nUrl: %s\nStatus Code: [%d]\n%s", r.URL, w.Code, w.Body.String())) beego.Debug("testing", testCase, fmt.Sprintf("\nUrl: %s\nStatus Code: [%d]\n%s", r.URL, w.Code, w.Body.String()))
return r, w return r, w
} }