分销商城(微商城)接口项目

default_test.go 949B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package test
  2. import (
  3. "net/http"
  4. "net/http/httptest"
  5. "testing"
  6. "runtime"
  7. "path/filepath"
  8. _ "wsc-go/routers"
  9. "github.com/astaxie/beego"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. func init() {
  13. _, file, _, _ := runtime.Caller(0)
  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. }