| 52 | } |
| 53 | |
| 54 | func TestHTMLBasic(t *testing.T) { |
| 55 | render := New(Options{ |
| 56 | Directory: "testdata/basic", |
| 57 | }) |
| 58 | |
| 59 | var err error |
| 60 | |
| 61 | h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 62 | err = render.HTML(w, http.StatusOK, "hello", "gophers") |
| 63 | }) |
| 64 | |
| 65 | res := httptest.NewRecorder() |
| 66 | req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/foo", nil) |
| 67 | h.ServeHTTP(res, req) |
| 68 | |
| 69 | expectNil(t, err) |
| 70 | expect(t, res.Code, 200) |
| 71 | expect(t, res.Header().Get(ContentType), ContentHTML+"; charset=UTF-8") |
| 72 | expect(t, res.Body.String(), "<h1>Hello gophers</h1>\n") |
| 73 | } |
| 74 | |
| 75 | func BenchmarkBigHTMLBuffers(b *testing.B) { |
| 76 | b.ReportAllocs() |