default_test.go 887B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package test
  2. import (
  3. _ "SCRM/routers"
  4. "net/http"
  5. "net/http/httptest"
  6. "path/filepath"
  7. "runtime"
  8. "testing"
  9. "github.com/astaxie/beego"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. func init() {
  13. _, file, _, _ := runtime.Caller(1)
  14. apppath, _ := filepath.Abs(filepath.Dir(filepath.Join(file, ".."+string(filepath.Separator))))
  15. beego.TestBeegoInit(apppath)
  16. }
  17. // TestBeego is a sample to run an endpoint test
  18. func TestBeego(t *testing.T) {
  19. r, _ := http.NewRequest("GET", "/", nil)
  20. w := httptest.NewRecorder()
  21. beego.BeeApp.Handlers.ServeHTTP(w, r)
  22. beego.Trace("testing", "TestBeego", "Code[%d]\n%s", w.Code, w.Body.String())
  23. Convey("Subject: Test Station Endpoint\n", t, func() {
  24. Convey("Status Code Should Be 200", func() {
  25. So(w.Code, ShouldEqual, 200)
  26. })
  27. Convey("The Result Should Not Be Empty", func() {
  28. So(w.Body.Len(), ShouldBeGreaterThan, 0)
  29. })
  30. })
  31. }