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