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

Function TestIOFSDirHTMLBasic

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

Source from the content-addressed store, hash-verified

71}
72
73func 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}

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
FSFunction · 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…