Skip to content

Commit 7bd0244

Browse files
committed
test: increase test coverage
1 parent 1f31354 commit 7bd0244

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

html_renderer/html_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package htmlrenderer
22

33
import (
4+
"errors"
45
"fmt"
56
"html/template"
67
"net/http/httptest"
@@ -10,6 +11,14 @@ import (
1011
"github.com/stretchr/testify/assert"
1112
)
1213

14+
type errWriter struct {
15+
*httptest.ResponseRecorder
16+
}
17+
18+
func (errWriter) Write(blob []byte) (int, error) {
19+
return 0, errors.New("new err")
20+
}
21+
1322
func newTestHTMLRenderer() *defaultHTMLRenderer {
1423
htmlRenderer := New("../testdata/templates/", "layouts/", ".html", false)
1524
return htmlRenderer
@@ -193,4 +202,8 @@ func TestDefaultHTMLRenderer_RenderHTML(t *testing.T) {
193202
fmt.Sprintf("%s<html><body>%s<p>Hello Tom</p>%s</body></html>%s", newline, newline, newline, newline),
194203
res.Body.String(),
195204
)
205+
206+
assert.Panics(t, func() {
207+
htmlRenderer.RenderHTML(errWriter{httptest.NewRecorder()}, "index.html", nil)
208+
})
196209
}

0 commit comments

Comments
 (0)