MCPcopy
hub / github.com/ory/kratos / TestCleanPath

Function TestCleanPath

x/clean_url_test.go:17–38  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestCleanPath(t *testing.T) {
18 r := http.NewServeMux()
19 r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
20 _, _ = w.Write([]byte(r.URL.String()))
21 })
22 ts := httptest.NewServer(r)
23 defer ts.Close()
24
25 for k, tc := range [][]string{
26 {"//foo", "/foo"},
27 {"//foo//bar", "/foo/bar"},
28 } {
29 t.Run(fmt.Sprintf("case=%d", k), func(t *testing.T) {
30 res, err := ts.Client().Get(ts.URL + tc[0])
31 require.NoError(t, err)
32 defer func() { _ = res.Body.Close() }()
33 body, err := io.ReadAll(res.Body)
34 require.NoError(t, err)
35 assert.Equal(t, string(body), tc[1])
36 })
37 }
38}

Callers

nothing calls this directly

Calls 6

StringMethod · 0.65
CloseMethod · 0.65
RunMethod · 0.65
ClientMethod · 0.65
WriteMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected