MCPcopy
hub / github.com/tdewolff/minify / TestMiddleware

Function TestMiddleware

minify_test.go:285–299  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

283}
284
285func TestMiddleware(t *testing.T) {
286 m := New()
287 m.AddFunc("text/html", func(m *M, w io.Writer, r io.Reader, _ map[string]string) error {
288 _, err := io.Copy(w, r)
289 return err
290 })
291
292 b := &bytes.Buffer{}
293 w := &testResponseWriter{b, http.Header{}}
294 r := &http.Request{RequestURI: "/index.html"}
295 m.Middleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
296 _, _ = w.Write([]byte("test"))
297 })).ServeHTTP(w, r)
298 test.String(t, b.String(), "test", "equal input after dummy minify middleware")
299}
300
301func TestHelperProcess(*testing.T) {
302 if os.Getenv("GO_WANT_HELPER_PROCESS") != "1" {

Callers

nothing calls this directly

Calls 5

WriteMethod · 0.95
NewFunction · 0.85
AddFuncMethod · 0.80
MiddlewareMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…