(t *testing.T)
| 123 | } |
| 124 | |
| 125 | func TestContextRenderTemplate(t *testing.T) { |
| 126 | e := New() |
| 127 | req := httptest.NewRequest(http.MethodPost, "/", strings.NewReader(userJSON)) |
| 128 | rec := httptest.NewRecorder() |
| 129 | |
| 130 | c := e.NewContext(req, rec) |
| 131 | |
| 132 | tmpl := &Template{ |
| 133 | templates: template.Must(template.New("hello").Parse("Hello, {{.}}!")), |
| 134 | } |
| 135 | c.Echo().Renderer = tmpl |
| 136 | err := c.Render(http.StatusOK, "hello", "Jon Snow") |
| 137 | if assert.NoError(t, err) { |
| 138 | assert.Equal(t, http.StatusOK, rec.Code) |
| 139 | assert.Equal(t, "Hello, Jon Snow!", rec.Body.String()) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func TestContextRenderTemplateError(t *testing.T) { |
| 144 | // we test that when template rendering fails, no response is sent to the client yet, so the global error handler can decide what to do |
nothing calls this directly
no test coverage detected
searching dependent graphs…