MCPcopy Create free account
hub / github.com/unrolled/render / TestHTMLBasic

Function TestHTMLBasic

render_html_test.go:54–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

52}
53
54func 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
75func BenchmarkBigHTMLBuffers(b *testing.B) {
76 b.ReportAllocs()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
expectNilFunction · 0.85
expectFunction · 0.85
HTMLMethod · 0.80
StringMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…