Sanity check that Content-Length set via serveBody matches body length.
(t *testing.T)
| 889 | proxy.HandlePeerGet(rec, req) |
| 890 | if rec.Code != http.StatusOK { |
| 891 | t.Errorf("HandlePeerGet: status = %d, want 200", rec.Code) |
| 892 | } |
| 893 | if got := rec.Body.String(); got != string(body) { |
| 894 | t.Errorf("HandlePeerGet body = %q, want %q", got, body) |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | func TestHandlePeerGetDoesNotCountWorkerCacheHit(t *testing.T) { |
| 899 | proxy := newTestProxy(t) |
| 900 | |
| 901 | key := strings.Repeat("e", 64) |
| 902 | body := []byte("peer-cached-payload") |
| 903 | if _, err := proxy.store.PutStream(key, bytes.NewReader(body)); err != nil { |
| 904 | t.Fatalf("seed PutStream: %v", err) |
| 905 | } |
| 906 | |
| 907 | hitsBefore := counterValue(t, cacheHitsTotal) |
| 908 | req := httptest.NewRequest(http.MethodGet, "/cache/get?key="+key, nil) |
| 909 | rec := httptest.NewRecorder() |
nothing calls this directly
no test coverage detected