Skip to content

Commit 38df488

Browse files
committed
修复测试用例
1 parent fea8f8d commit 38df488

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

http/middleware/recovery/recovery_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Test_Recovery(t *testing.T) {
3030
should.NoError(err)
3131

3232
router.ServeHTTP(recorder, req)
33-
should.Equal(recorder.Code, http.StatusInternalServerError)
33+
should.Equal(recorder.Code, http.StatusOK)
3434
}
3535

3636
func init() {

http/response/send.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func Failed(w http.ResponseWriter, err error) {
3838

3939
// set response heanders
4040
w.Header().Set("Content-Type", "application/json")
41+
w.Header().Set("Err-Code", fmt.Sprintf("%d", errCode))
4142

4243
// if marshal json error, use string to response
4344
respByt, err := json.Marshal(resp)

http/router/httprouter/httprouter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func TestWithAutherFailed(t *testing.T) {
115115
r.Handle("GET", "/", IndexHandler).EnableAuth()
116116
r.ServeHTTP(w, req)
117117

118-
should.Equal(401, w.Code)
118+
should.Equal(200, w.Code)
119119
}
120120

121121
func TestWithAutherOK(t *testing.T) {
@@ -160,7 +160,7 @@ func TestWithParamsFailed(t *testing.T) {
160160
r.Handle("GET", "/:id", WithContextHandler)
161161
r.ServeHTTP(w, req)
162162

163-
should.Equal(400, w.Code)
163+
should.Equal(200, w.Code)
164164
}
165165

166166
func TestSetLabel(t *testing.T) {

0 commit comments

Comments
 (0)