Renamed panic render to render in context test

This commit is contained in:
eeonevision 2023-01-10 16:09:18 +03:00
parent 9a45526592
commit f32da2dc73

View File

@ -32,7 +32,7 @@ import (
var _ context.Context = (*Context)(nil) var _ context.Context = (*Context)(nil)
var errTestPanicRender = errors.New("TestPanicRender") var errTestRender = errors.New("TestRender")
// Unit tests TODO // Unit tests TODO
// func (c *Context) File(filepath string) { // func (c *Context) File(filepath string) {
@ -645,21 +645,21 @@ func TestContextBodyAllowedForStatus(t *testing.T) {
assert.True(t, true, bodyAllowedForStatus(http.StatusInternalServerError)) assert.True(t, true, bodyAllowedForStatus(http.StatusInternalServerError))
} }
type TestPanicRender struct{} type TestRender struct{}
func (*TestPanicRender) Render(http.ResponseWriter) error { func (*TestRender) Render(http.ResponseWriter) error {
return errTestPanicRender return errTestRender
} }
func (*TestPanicRender) WriteContentType(http.ResponseWriter) {} func (*TestRender) WriteContentType(http.ResponseWriter) {}
func TestContextRenderIfErr(t *testing.T) { func TestContextRenderIfErr(t *testing.T) {
w := httptest.NewRecorder() w := httptest.NewRecorder()
c, _ := CreateTestContext(w) 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 // Tests that the response is serialized as JSON