MCPcopy Index your code
hub / github.com/unrolled/render / TestDataBinaryBasic

Function TestDataBinaryBasic

render_data_test.go:9–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestDataBinaryBasic(t *testing.T) {
10 render := New(Options{
11 // nothing here to configure
12 })
13
14 var err error
15
16 h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
17 err = render.Data(w, 299, []byte("hello there"))
18 })
19
20 res := httptest.NewRecorder()
21 req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/foo", nil)
22 h.ServeHTTP(res, req)
23
24 expectNil(t, err)
25 expect(t, res.Code, 299)
26 expect(t, res.Header().Get(ContentType), ContentBinary)
27 expect(t, res.Body.String(), "hello there")
28}
29
30func TestDataCustomMimeType(t *testing.T) {
31 render := New(Options{

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
expectNilFunction · 0.85
expectFunction · 0.85
DataMethod · 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…