MCPcopy
hub / github.com/go-chi/chi / TestTree

Function TestTree

tree_test.go:10–152  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

8)
9
10func TestTree(t *testing.T) {
11 hStub := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
12 hIndex := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
13 hFavicon := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
14 hArticleList := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
15 hArticleNear := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
16 hArticleShow := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
17 hArticleShowRelated := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
18 hArticleShowOpts := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
19 hArticleSlug := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
20 hArticleByUser := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
21 hUserList := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
22 hUserShow := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
23 hAdminCatchall := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
24 hAdminAppShow := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
25 hAdminAppShowCatchall := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
26 hUserProfile := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
27 hUserSuper := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
28 hUserAll := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
29 hHubView1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
30 hHubView2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
31 hHubView3 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
32
33 tr := &node{}
34
35 tr.InsertRoute(mGET, "/", hIndex)
36 tr.InsertRoute(mGET, "/favicon.ico", hFavicon)
37
38 tr.InsertRoute(mGET, "/pages/*", hStub)
39
40 tr.InsertRoute(mGET, "/article", hArticleList)
41 tr.InsertRoute(mGET, "/article/", hArticleList)
42
43 tr.InsertRoute(mGET, "/article/near", hArticleNear)
44 tr.InsertRoute(mGET, "/article/{id}", hStub)
45 tr.InsertRoute(mGET, "/article/{id}", hArticleShow)
46 tr.InsertRoute(mGET, "/article/{id}", hArticleShow) // duplicate will have no effect
47 tr.InsertRoute(mGET, "/article/@{user}", hArticleByUser)
48
49 tr.InsertRoute(mGET, "/article/{sup}/{opts}", hArticleShowOpts)
50 tr.InsertRoute(mGET, "/article/{id}/{opts}", hArticleShowOpts) // overwrite above route, latest wins
51
52 tr.InsertRoute(mGET, "/article/{iffd}/edit", hStub)
53 tr.InsertRoute(mGET, "/article/{id}//related", hArticleShowRelated)
54 tr.InsertRoute(mGET, "/article/slug/{month}/-/{day}/{year}", hArticleSlug)
55
56 tr.InsertRoute(mGET, "/admin/user", hUserList)
57 tr.InsertRoute(mGET, "/admin/user/", hStub) // will get replaced by next route
58 tr.InsertRoute(mGET, "/admin/user/", hUserList)
59
60 tr.InsertRoute(mGET, "/admin/user//{id}", hUserShow)
61 tr.InsertRoute(mGET, "/admin/user/{id}", hUserShow)
62
63 tr.InsertRoute(mGET, "/admin/apps/{id}", hAdminAppShow)
64 tr.InsertRoute(mGET, "/admin/apps/{id}/*", hAdminAppShowCatchall)
65
66 tr.InsertRoute(mGET, "/admin/*", hStub) // catchall segment will get replaced by next route
67 tr.InsertRoute(mGET, "/admin/*", hAdminCatchall)

Callers

nothing calls this directly

Calls 7

InsertRouteMethod · 0.95
GetMethod · 0.95
FindRouteMethod · 0.95
NewRouterFunction · 0.85
NewRouteContextFunction · 0.85
stringSliceEqualFunction · 0.85
HandlerFuncMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…