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