Home / Function/ TestRouteContextHoldsFullPath() — gin Function Reference

TestRouteContextHoldsFullPath() — gin Function Reference

Architecture documentation for the TestRouteContextHoldsFullPath() function in routes_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  8497488d_6922_db5f_cabb_e1d89825c703["TestRouteContextHoldsFullPath()"]
  45929e18_70ca_7c55_01e0_596be99dd824["routes_test.go"]
  8497488d_6922_db5f_cabb_e1d89825c703 -->|defined in| 45929e18_70ca_7c55_01e0_596be99dd824
  9785c910_0083_377a_37b6_92b299e0e32d["PerformRequest()"]
  8497488d_6922_db5f_cabb_e1d89825c703 -->|calls| 9785c910_0083_377a_37b6_92b299e0e32d
  style 8497488d_6922_db5f_cabb_e1d89825c703 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

routes_test.go lines 731–772

func TestRouteContextHoldsFullPath(t *testing.T) {
	router := New()

	// Test routes
	routes := []string{
		"/simple",
		"/project/:name",
		"/",
		"/news/home",
		"/news",
		"/simple-two/one",
		"/simple-two/one-two",
		"/project/:name/build/*params",
		"/project/:name/bui",
		"/user/:id/status",
		"/user/:id",
		"/user/:id/profile",
	}

	for _, route := range routes {
		actualRoute := route
		router.GET(route, func(c *Context) {
			// For each defined route context should contain its full path
			assert.Equal(t, actualRoute, c.FullPath())
			c.AbortWithStatus(http.StatusOK)
		})
	}

	for _, route := range routes {
		w := PerformRequest(router, http.MethodGet, route)
		assert.Equal(t, http.StatusOK, w.Code)
	}

	// Test not found
	router.Use(func(c *Context) {
		// For not found routes full path is empty
		assert.Empty(t, c.FullPath())
	})

	w := PerformRequest(router, http.MethodGet, "/not-found")
	assert.Equal(t, http.StatusNotFound, w.Code)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestRouteContextHoldsFullPath() do?
TestRouteContextHoldsFullPath() is a function in the gin codebase, defined in routes_test.go.
Where is TestRouteContextHoldsFullPath() defined?
TestRouteContextHoldsFullPath() is defined in routes_test.go at line 731.
What does TestRouteContextHoldsFullPath() call?
TestRouteContextHoldsFullPath() calls 1 function(s): PerformRequest.

Analyze Your Own Codebase

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

Try Supermodel Free