http, cache: Expose cache stats

This commit is contained in:
Martin Polden
2020-09-11 20:52:35 +02:00
parent df49848167
commit ceaff84709
3 changed files with 49 additions and 0 deletions

View File

@ -160,6 +160,21 @@ func TestJSONHandlers(t *testing.T) {
}
}
func TestCacheHandler(t *testing.T) {
log.SetOutput(ioutil.Discard)
srv := testServer()
srv.profile = true
s := httptest.NewServer(srv.Handler())
got, _, err := httpGet(s.URL+"/debug/cache/", jsonMediaType, "")
if err != nil {
t.Fatal(err)
}
want := `{"size":0,"capacity":100}`
if got != want {
t.Errorf("got %q, want %q", got, want)
}
}
func TestIPFromRequest(t *testing.T) {
var tests = []struct {
remoteAddr string