MCPcopy Create free account
hub / github.com/Azure/peerd / TestP2pPeerNotFound

Function TestP2pPeerNotFound

pkg/discovery/content/reader/reader_test.go:269–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

267}
268
269func TestP2pPeerNotFound(t *testing.T) {
270 l := zerolog.Nop()
271 m := map[string][]string{}
272
273 req, err := http.NewRequest("GET", "http://127.0.0.1:5000/blobs/"+u, nil)
274 if err != nil {
275 t.Fatal(err)
276 }
277
278 router := mocks.NewMockRouter(m)
279 c, _ := gin.CreateTestContext(httptest.NewRecorder())
280 c.Request = req
281
282 r := NewReader(pcontext.FromContext(c), router, 3, 500*time.Millisecond, mr).(*reader)
283
284 b := make([]byte, 10)
285 _, err = r.doP2p(l, "key", 0, 10, operationPreadRemote, b)
286 if err == nil {
287 t.Fatal("expected error")
288 }
289
290 if err != errPeerNotFound {
291 t.Fatalf("expected %v, got %v", errPeerNotFound, err)
292 }
293}
294
295func TestP2pNoInfiniteLoops(t *testing.T) {
296 l := zerolog.Nop()

Callers

nothing calls this directly

Calls 3

NewMockRouterFunction · 0.92
NewReaderFunction · 0.85
doP2pMethod · 0.80

Tested by

no test coverage detected