MCPcopy
hub / github.com/labstack/echo / TestEchoWrapHandler

Function TestEchoWrapHandler

echo_test.go:709–729  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

707}
708
709func TestEchoWrapHandler(t *testing.T) {
710 e := New()
711
712 var actualID string
713 var actualPattern string
714 e.GET("/:id", WrapHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
715 w.WriteHeader(http.StatusOK)
716 w.Write([]byte("test"))
717 actualID = r.PathValue("id")
718 actualPattern = r.Pattern
719 })))
720
721 req := httptest.NewRequest(http.MethodGet, "/123", nil)
722 rec := httptest.NewRecorder()
723 e.ServeHTTP(rec, req)
724
725 assert.Equal(t, http.StatusOK, rec.Code)
726 assert.Equal(t, "test", rec.Body.String())
727 assert.Equal(t, "123", actualID)
728 assert.Equal(t, "/:id", actualPattern)
729}
730
731func TestEchoWrapMiddleware(t *testing.T) {
732 e := New()

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
WrapHandlerFunction · 0.85
ServeHTTPMethod · 0.80
GETMethod · 0.45
WriteHeaderMethod · 0.45
WriteMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…