TestErrorLogger() — gin Function Reference
Architecture documentation for the TestErrorLogger() function in logger_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 923ef616_cb63_b837_2150_a5699b441355["TestErrorLogger()"] 9089ba1c_3991_2941_2a87_9934a9e12a6a["logger_test.go"] 923ef616_cb63_b837_2150_a5699b441355 -->|defined in| 9089ba1c_3991_2941_2a87_9934a9e12a6a style 923ef616_cb63_b837_2150_a5699b441355 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
logger_test.go lines 375–400
func TestErrorLogger(t *testing.T) {
router := New()
router.Use(ErrorLogger())
router.GET("/error", func(c *Context) {
c.Error(errors.New("this is an error")) //nolint: errcheck
})
router.GET("/abort", func(c *Context) {
c.AbortWithError(http.StatusUnauthorized, errors.New("no authorized")) //nolint: errcheck
})
router.GET("/print", func(c *Context) {
c.Error(errors.New("this is an error")) //nolint: errcheck
c.String(http.StatusInternalServerError, "hola!")
})
w := PerformRequest(router, http.MethodGet, "/error")
assert.Equal(t, http.StatusOK, w.Code)
assert.JSONEq(t, "{\"error\":\"this is an error\"}", w.Body.String())
w = PerformRequest(router, http.MethodGet, "/abort")
assert.Equal(t, http.StatusUnauthorized, w.Code)
assert.JSONEq(t, "{\"error\":\"no authorized\"}", w.Body.String())
w = PerformRequest(router, http.MethodGet, "/print")
assert.Equal(t, http.StatusInternalServerError, w.Code)
assert.Equal(t, "hola!{\"error\":\"this is an error\"}", w.Body.String())
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestErrorLogger() do?
TestErrorLogger() is a function in the gin codebase, defined in logger_test.go.
Where is TestErrorLogger() defined?
TestErrorLogger() is defined in logger_test.go at line 375.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free