fix: resolve flaky ffmpeg context cancellation test

Replaced single Read assertion with Eventually loop to drain buffered
pipe data after context cancellation. The previous test assumed the first
Read after cancel() would fail, but ffmpeg may have already written data
into the pipe buffer before being killed, causing the Read to succeed
from buffered content.
This commit is contained in:
Deluan
2026-03-27 19:38:42 -04:00
parent f33ca75378
commit 2588558946
+6 -3
View File
@@ -584,9 +584,12 @@ var _ = Describe("ffmpeg", func() {
// Cancel the context
cancel()
// Next read should fail due to cancelled context
_, err = stream.Read(buf)
Expect(err).To(HaveOccurred())
// Subsequent reads should eventually fail due to cancelled context.
// There may be buffered data in the pipe, so we drain until an error occurs.
Eventually(func() error {
_, err = stream.Read(buf)
return err
}).WithTimeout(5 * time.Second).WithPolling(10 * time.Millisecond).Should(HaveOccurred())
})
It("should handle immediate context cancellation", func() {