(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func 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 | |
| 46 | func TestIndexPageContent(t *testing.T) { |
| 47 | c := newIndexPageContent() |
nothing calls this directly
no test coverage detected