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

Function TestMuxRegexp2

mux_test.go:1596–1610  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1594}
1595
1596func TestMuxRegexp2(t *testing.T) {
1597 r := NewRouter()
1598 r.Get("/foo-{suffix:[a-z]{2,3}}.json", func(w http.ResponseWriter, r *http.Request) {
1599 w.Write([]byte(URLParam(r, "suffix")))
1600 })
1601 ts := httptest.NewServer(r)
1602 defer ts.Close()
1603
1604 if _, body := testRequest(t, ts, "GET", "/foo-.json", nil); body != "" {
1605 t.Fatal(body)
1606 }
1607 if _, body := testRequest(t, ts, "GET", "/foo-abc.json", nil); body != "abc" {
1608 t.Fatal(body)
1609 }
1610}
1611
1612func TestMuxRegexp3(t *testing.T) {
1613 r := NewRouter()

Callers

nothing calls this directly

Calls 6

GetMethod · 0.95
NewRouterFunction · 0.85
URLParamFunction · 0.85
CloseMethod · 0.80
testRequestFunction · 0.70
WriteMethod · 0.65

Tested by

no test coverage detected