MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / TestAsyncBufferThresholdInstantBeyondAccess

Function TestAsyncBufferThresholdInstantBeyondAccess

asyncbuffer/buffer_test.go:487–501  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

485}
486
487func TestAsyncBufferThresholdInstantBeyondAccess(t *testing.T) {
488 _, bytesReader := generateSourceData(t, asyncbuffer.PauseThreshold*3)
489 ab := asyncbuffer.New(bytesReader, -1)
490 defer ab.Close()
491
492 target := make([]byte, asyncbuffer.ChunkSize)
493 n, err := ab.ReadAt(target, asyncbuffer.PauseThreshold+1)
494 require.NoError(t, err)
495 assert.GreaterOrEqual(t, asyncbuffer.ChunkSize, n)
496
497 // Ensure that buffer hits the end of the stream
498 require.Eventually(t, func() bool {
499 return bytesReader.BytesRead() >= asyncbuffer.PauseThreshold*2
500 }, 300*time.Millisecond, 10*time.Millisecond)
501}

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
generateSourceDataFunction · 0.85
ReadAtMethod · 0.80
BytesReadMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected