Home / Function/ TestTreeWildcardConflictEx() — gin Function Reference

TestTreeWildcardConflictEx() — gin Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

tree_test.go lines 942–978

func TestTreeWildcardConflictEx(t *testing.T) {
	conflicts := [...]struct {
		route        string
		segPath      string
		existPath    string
		existSegPath string
	}{
		{"/who/are/foo", "/foo", `/who/are/\*you`, `/\*you`},
		{"/who/are/foo/", "/foo/", `/who/are/\*you`, `/\*you`},
		{"/who/are/foo/bar", "/foo/bar", `/who/are/\*you`, `/\*you`},
		{"/con:nection", ":nection", `/con:tact`, `:tact`},
	}

	for _, conflict := range conflicts {
		// I have to re-create a 'tree', because the 'tree' will be
		// in an inconsistent state when the loop recovers from the
		// panic which threw by 'addRoute' function.
		tree := &node{}
		routes := [...]string{
			"/con:tact",
			"/who/are/*you",
			"/who/foo/hello",
		}

		for _, route := range routes {
			tree.addRoute(route, fakeHandler(route))
		}

		recv := catchPanic(func() {
			tree.addRoute(conflict.route, fakeHandler(conflict.route))
		})

		if !regexp.MustCompile(fmt.Sprintf("'%s' in new path .* conflicts with existing wildcard '%s' in existing prefix '%s'", conflict.segPath, conflict.existSegPath, conflict.existPath)).MatchString(fmt.Sprint(recv)) {
			t.Fatalf("invalid wildcard conflict error (%v)", recv)
		}
	}
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestTreeWildcardConflictEx() do?
TestTreeWildcardConflictEx() is a function in the gin codebase, defined in tree_test.go.
Where is TestTreeWildcardConflictEx() defined?
TestTreeWildcardConflictEx() is defined in tree_test.go at line 942.
What does TestTreeWildcardConflictEx() call?
TestTreeWildcardConflictEx() calls 2 function(s): catchPanic, fakeHandler.

Analyze Your Own Codebase

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

Try Supermodel Free