| 71 | } |
| 72 | |
| 73 | func TestIOFSDirHTMLBasic(t *testing.T) { |
| 74 | render := New(Options{ |
| 75 | Directory: ".", |
| 76 | FileSystem: FS(os.DirFS("testdata/basic")), |
| 77 | }) |
| 78 | |
| 79 | var err error |
| 80 | |
| 81 | h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 82 | err = render.HTML(w, http.StatusOK, "hello", "gophers") |
| 83 | }) |
| 84 | |
| 85 | res := httptest.NewRecorder() |
| 86 | req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/foo", nil) |
| 87 | h.ServeHTTP(res, req) |
| 88 | |
| 89 | expectNil(t, err) |
| 90 | expect(t, res.Code, 200) |
| 91 | expect(t, res.Header().Get(ContentType), ContentHTML+"; charset=UTF-8") |
| 92 | expect(t, res.Body.String(), "<h1>Hello gophers</h1>\n") |
| 93 | } |