mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 21:06:39 +08:00
optimize code
Signed-off-by: Flc゛ <four_leaf_clover@foxmail.com>
This commit is contained in:
parent
df5c54fd31
commit
83dee28737
@ -1409,13 +1409,13 @@ func TestContextError(t *testing.T) {
|
||||
t.Error("didn't panic")
|
||||
}
|
||||
}()
|
||||
c.Error(nil) // nolint: errcheck
|
||||
c.Error(nil) //nolint: errcheck
|
||||
}
|
||||
|
||||
func TestContextTypedError(t *testing.T) {
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Error(errors.New("externo 0")).SetType(ErrorTypePublic) // nolint: errcheck
|
||||
c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) // nolint: errcheck
|
||||
c.Error(errors.New("externo 0")).SetType(ErrorTypePublic) //nolint: errcheck
|
||||
c.Error(errors.New("interno 0")).SetType(ErrorTypePrivate) //nolint: errcheck
|
||||
|
||||
for _, err := range c.Errors.ByType(ErrorTypePublic) {
|
||||
assert.Equal(t, ErrorTypePublic, err.Type)
|
||||
@ -1430,7 +1430,7 @@ func TestContextAbortWithError(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := CreateTestContext(w)
|
||||
|
||||
c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") // nolint: errcheck
|
||||
c.AbortWithError(http.StatusUnauthorized, errors.New("bad input")).SetMeta("some input") //nolint: errcheck
|
||||
|
||||
assert.Equal(t, http.StatusUnauthorized, w.Code)
|
||||
assert.Equal(t, abortIndex, c.index)
|
||||
|
Loading…
x
Reference in New Issue
Block a user