MCPcopy Create free account
hub / github.com/BryanMwangi/pine / TestRouter_MethodIsolation

Function TestRouter_MethodIsolation

router_test.go:138–156  ·  view source on GitHub ↗

--------------------------------------------------------------------------- Method isolation ---------------------------------------------------------------------------

(t *testing.T)

Source from the content-addressed store, hash-verified

136// ---------------------------------------------------------------------------
137
138func TestRouter_MethodIsolation(t *testing.T) {
139 r := newTestRouter()
140 insertRoute(r, "GET", "/res")
141 insertRoute(r, "POST", "/res")
142 insertRoute(r, "DELETE", "/res")
143
144 for _, method := range []string{"GET", "POST", "DELETE"} {
145 _, _, found := r.Search(method, "/res")
146 if !found {
147 t.Errorf("expected to find %s /res", method)
148 }
149 }
150
151 // Wrong method — path exists but wrong method → not found at router level.
152 _, _, found := r.Search("PUT", "/res")
153 if found {
154 t.Error("PUT /res should not be found (not registered)")
155 }
156}
157
158func TestRouter_SearchAnyMethod(t *testing.T) {
159 r := newTestRouter()

Callers

nothing calls this directly

Calls 4

newTestRouterFunction · 0.85
insertRouteFunction · 0.85
SearchMethod · 0.80
ErrorMethod · 0.80

Tested by

no test coverage detected