Home / Function/ TestWrap() — gin Function Reference

TestWrap() — gin Function Reference

Architecture documentation for the TestWrap() function in utils_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  1f77e12e_fa55_5c3d_a82e_b3a4f58b282c["TestWrap()"]
  40dd6e0f_7abb_6ce7_1b7d_0ff510263efc["utils_test.go"]
  1f77e12e_fa55_5c3d_a82e_b3a4f58b282c -->|defined in| 40dd6e0f_7abb_6ce7_1b7d_0ff510263efc
  style 1f77e12e_fa55_5c3d_a82e_b3a4f58b282c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

utils_test.go lines 39–56

func TestWrap(t *testing.T) {
	router := New()
	router.POST("/path", WrapH(&testStruct{t}))
	router.GET("/path2", WrapF(func(w http.ResponseWriter, req *http.Request) {
		assert.Equal(t, http.MethodGet, req.Method)
		assert.Equal(t, "/path2", req.URL.Path)
		w.WriteHeader(http.StatusBadRequest)
		fmt.Fprint(w, "hola!")
	}))

	w := PerformRequest(router, http.MethodPost, "/path")
	assert.Equal(t, http.StatusInternalServerError, w.Code)
	assert.Equal(t, "hello", w.Body.String())

	w = PerformRequest(router, http.MethodGet, "/path2")
	assert.Equal(t, http.StatusBadRequest, w.Code)
	assert.Equal(t, "hola!", w.Body.String())
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestWrap() do?
TestWrap() is a function in the gin codebase, defined in utils_test.go.
Where is TestWrap() defined?
TestWrap() is defined in utils_test.go at line 39.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free