Home / Function/ TestTreeTrailingSlashRedirect() — gin Function Reference

TestTreeTrailingSlashRedirect() — gin Function Reference

Architecture documentation for the TestTreeTrailingSlashRedirect() function in tree_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  b4eebcb1_920d_402e_a04f_cdbf3dab0aad["TestTreeTrailingSlashRedirect()"]
  95642d64_cc2a_14f0_a93c_52464b2a60b9["tree_test.go"]
  b4eebcb1_920d_402e_a04f_cdbf3dab0aad -->|defined in| 95642d64_cc2a_14f0_a93c_52464b2a60b9
  e88fa484_0d98_1d59_f804_c3948a6745fe["catchPanic()"]
  b4eebcb1_920d_402e_a04f_cdbf3dab0aad -->|calls| e88fa484_0d98_1d59_f804_c3948a6745fe
  93c1c821_291f_3e71_2ae0_563c40ff3ee5["fakeHandler()"]
  b4eebcb1_920d_402e_a04f_cdbf3dab0aad -->|calls| 93c1c821_291f_3e71_2ae0_563c40ff3ee5
  e7a2b9cb_792d_4373_e0f6_32e424a8c5db["getSkippedNodes()"]
  b4eebcb1_920d_402e_a04f_cdbf3dab0aad -->|calls| e7a2b9cb_792d_4373_e0f6_32e424a8c5db
  style b4eebcb1_920d_402e_a04f_cdbf3dab0aad fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

tree_test.go lines 570–674

func TestTreeTrailingSlashRedirect(t *testing.T) {
	tree := &node{}

	routes := [...]string{
		"/hi",
		"/b/",
		"/search/:query",
		"/cmd/:tool/",
		"/src/*filepath",
		"/x",
		"/x/y",
		"/y/",
		"/y/z",
		"/0/:id",
		"/0/:id/1",
		"/1/:id/",
		"/1/:id/2",
		"/aa",
		"/a/",
		"/admin",
		"/admin/:category",
		"/admin/:category/:page",
		"/doc",
		"/doc/go_faq.html",
		"/doc/go1.html",
		"/no/a",
		"/no/b",
		"/api/:page/:name",
		"/api/hello/:name/bar/",
		"/api/bar/:name",
		"/api/baz/foo",
		"/api/baz/foo/bar",
		"/blog/:p",
		"/posts/:b/:c",
		"/posts/b/:c/d/",
		"/vendor/:x/*y",
	}
	for _, route := range routes {
		recv := catchPanic(func() {
			tree.addRoute(route, fakeHandler(route))
		})
		if recv != nil {
			t.Fatalf("panic inserting route '%s': %v", route, recv)
		}
	}

	tsrRoutes := [...]string{
		"/hi/",
		"/b",
		"/search/gopher/",
		"/cmd/vet",
		"/src",
		"/x/",
		"/y",
		"/0/go/",
		"/1/go",
		"/a",
		"/admin/",
		"/admin/config/",
		"/admin/config/permissions/",
		"/doc/",
		"/admin/static/",
		"/admin/cfg/",
		"/admin/cfg/users/",
		"/api/hello/x/bar",
		"/api/baz/foo/",
		"/api/baz/bax/",
		"/api/bar/huh/",
		"/api/baz/foo/bar/",
		"/api/world/abc/",
		"/blog/pp/",
		"/posts/b/c/d",
		"/vendor/x",
	}

	for _, route := range tsrRoutes {
		value := tree.getValue(route, nil, getSkippedNodes(), false)
		if value.handlers != nil {
			t.Fatalf("non-nil handler for TSR route '%s", route)
		} else if !value.tsr {
			t.Errorf("expected TSR recommendation for route '%s'", route)

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestTreeTrailingSlashRedirect() do?
TestTreeTrailingSlashRedirect() is a function in the gin codebase, defined in tree_test.go.
Where is TestTreeTrailingSlashRedirect() defined?
TestTreeTrailingSlashRedirect() is defined in tree_test.go at line 570.
What does TestTreeTrailingSlashRedirect() call?
TestTreeTrailingSlashRedirect() calls 3 function(s): catchPanic, fakeHandler, getSkippedNodes.

Analyze Your Own Codebase

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

Try Supermodel Free