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
  0a9e6c66_a802_76fb_d8a7_111bca5b1cc5["TestTreeWildcardConflictEx()"]
  6dab8d3e_0986_1500_b06f_6323ea7ce91a["fakeHandler()"]
  0a9e6c66_a802_76fb_d8a7_111bca5b1cc5 -->|calls| 6dab8d3e_0986_1500_b06f_6323ea7ce91a
  7d17d111_6d55_8539_e0ed_b32eea9e5ef6["catchPanic()"]
  0a9e6c66_a802_76fb_d8a7_111bca5b1cc5 -->|calls| 7d17d111_6d55_8539_e0ed_b32eea9e5ef6
  style 0a9e6c66_a802_76fb_d8a7_111bca5b1cc5 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

Frequently Asked Questions

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