| 7 | ) |
| 8 | |
| 9 | func 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 | |
| 30 | func TestDataCustomMimeType(t *testing.T) { |
| 31 | render := New(Options{ |