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

Function TestTreeFindPattern

tree_test.go:417–445  ·  tree_test.go::TestTreeFindPattern
(t *testing.T)

Source from the content-addressed store, hash-verified

415}
416
417func TestTreeFindPattern(t *testing.T) {
418 hStub1 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
419 hStub2 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
420 hStub3 := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
421
422 tr := &node{}
423 tr.InsertRoute(mGET, "/pages/*", hStub1)
424 tr.InsertRoute(mGET, "/articles/{id}/*", hStub2)
425 tr.InsertRoute(mGET, "/articles/{slug}/{uid}/*", hStub3)
426
427 if tr.findPattern("/pages") != false {
428 t.Errorf("find /pages failed")
429 }
430 if tr.findPattern("/pages*") != false {
431 t.Errorf("find /pages* failed - should be nil")
432 }
433 if tr.findPattern("/pages/*") == false {
434 t.Errorf("find /pages/* failed")
435 }
436 if tr.findPattern("/articles/{id}/*") == false {
437 t.Errorf("find /articles/{id}/* failed")
438 }
439 if tr.findPattern("/articles/{something}/*") == false {
440 t.Errorf("find /articles/{something}/* failed")
441 }
442 if tr.findPattern("/articles/{slug}/{uid}/*") == false {
443 t.Errorf("find /articles/{slug}/{uid}/* failed")
444 }
445}
446
447func debugPrintTree(parent int, i int, n *node, label byte) bool {
448 numEdges := 0

Callers

nothing calls this directly

Calls 3

InsertRouteMethod · 0.95
findPatternMethod · 0.95
HandlerFuncMethod · 0.80

Tested by

no test coverage detected