forked from Ptt-official-app/go-pttbbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_index_test.go
51 lines (44 loc) · 903 Bytes
/
test_index_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/Ptt-official-app/go-pttbbs/api"
)
func Test_Index(t *testing.T) {
setupTest()
defer teardownTest()
params := &api.IndexParams{}
type args struct {
path string
userID string
passwd string
params interface{}
}
tests := []struct {
name string
args args
}{
// TODO: Add test cases.
{
args: args{
path: api.INDEX_R,
userID: "SYSOP",
passwd: "123123",
params: params,
}, // json: input: {}, output: {"Data": "index"}
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
router, _ := initGin()
jwt := getJwt(router, tt.args.userID, tt.args.passwd)
w := httptest.NewRecorder()
req := setRequest(tt.args.path, params, jwt, nil, "POST")
router.ServeHTTP(w, req)
if w.Code != http.StatusOK {
t.Errorf("code: %v", w.Code)
}
})
}
}