mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 13:22:09 +08:00
Renamed panic render to render in context test
This commit is contained in:
parent
9a45526592
commit
f32da2dc73
@ -32,7 +32,7 @@ import (
|
||||
|
||||
var _ context.Context = (*Context)(nil)
|
||||
|
||||
var errTestPanicRender = errors.New("TestPanicRender")
|
||||
var errTestRender = errors.New("TestRender")
|
||||
|
||||
// Unit tests TODO
|
||||
// func (c *Context) File(filepath string) {
|
||||
@ -645,21 +645,21 @@ func TestContextBodyAllowedForStatus(t *testing.T) {
|
||||
assert.True(t, true, bodyAllowedForStatus(http.StatusInternalServerError))
|
||||
}
|
||||
|
||||
type TestPanicRender struct{}
|
||||
type TestRender struct{}
|
||||
|
||||
func (*TestPanicRender) Render(http.ResponseWriter) error {
|
||||
return errTestPanicRender
|
||||
func (*TestRender) Render(http.ResponseWriter) error {
|
||||
return errTestRender
|
||||
}
|
||||
|
||||
func (*TestPanicRender) WriteContentType(http.ResponseWriter) {}
|
||||
func (*TestRender) WriteContentType(http.ResponseWriter) {}
|
||||
|
||||
func TestContextRenderIfErr(t *testing.T) {
|
||||
w := httptest.NewRecorder()
|
||||
c, _ := CreateTestContext(w)
|
||||
|
||||
c.Render(http.StatusOK, &TestPanicRender{})
|
||||
c.Render(http.StatusOK, &TestRender{})
|
||||
|
||||
assert.Equal(t, errorMsgs{&Error{Err: errTestPanicRender, Type: 1}}, c.Errors)
|
||||
assert.Equal(t, errorMsgs{&Error{Err: errTestRender, Type: 1}}, c.Errors)
|
||||
}
|
||||
|
||||
// Tests that the response is serialized as JSON
|
||||
|
Loading…
x
Reference in New Issue
Block a user