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:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user