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
  b6a9f652_93f1_ba69_1de2_444c6d998cfa["TestRouteContextHoldsFullPath()"]
  69c2add5_555a_3d82_a4e7_993886631a2c["PerformRequest()"]
  b6a9f652_93f1_ba69_1de2_444c6d998cfa -->|calls| 69c2add5_555a_3d82_a4e7_993886631a2c
  style b6a9f652_93f1_ba69_1de2_444c6d998cfa 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

Frequently Asked Questions

What does TestRouteContextHoldsFullPath() do?
TestRouteContextHoldsFullPath() is a function in the gin codebase.
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