MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestIndexHandlerPrefix

Function TestIndexHandlerPrefix

pkg/api/handlers_test.go:21–44  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestIndexHandlerPrefix(t *testing.T) {
22 c := newIndexPageContent()
23 c.AddLink(SectionAdminEndpoints, "/ingester/ring", "Ingester Ring")
24
25 for _, tc := range []struct {
26 prefix string
27 toBeFound string
28 }{
29 {prefix: "", toBeFound: "<a href=\"/ingester/ring\">"},
30 {prefix: "/test", toBeFound: "<a href=\"/test/ingester/ring\">"},
31 // All the extra slashed are cleaned up in the result.
32 {prefix: "///test///", toBeFound: "<a href=\"/test/ingester/ring\">"},
33 } {
34 h := indexHandler(tc.prefix, c)
35
36 req := httptest.NewRequest("GET", "/", nil)
37 resp := httptest.NewRecorder()
38
39 h.ServeHTTP(resp, req)
40
41 require.Equal(t, 200, resp.Code)
42 require.True(t, strings.Contains(resp.Body.String(), tc.toBeFound))
43 }
44}
45
46func TestIndexPageContent(t *testing.T) {
47 c := newIndexPageContent()

Callers

nothing calls this directly

Calls 6

newIndexPageContentFunction · 0.85
indexHandlerFunction · 0.85
AddLinkMethod · 0.80
EqualMethod · 0.65
StringMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected