Skip to content

Commit

Permalink
streamer/audio: fixed failing test
Browse files Browse the repository at this point in the history
Test assumed any .Read would see all data that was passed to a Write
but this is not necessarily true anymore now that it uses memfd as
backing.
  • Loading branch information
Wessie committed Dec 24, 2024
1 parent 9bc4046 commit 80cc2c2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions streamer/audio/pcm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package audio
import (
"bytes"
"crypto/rand"
"io"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -41,7 +42,7 @@ func TestPCMBuffer(t *testing.T) {
t.Logf("playback length reader: %s", pr.TotalLength())
t.Logf("playback progress reader: %s", pr.Progress())

n, err = pr.Read(data2)
n, err = io.ReadAtLeast(pr, data2, len(data2))
require.NoError(t, err)
require.Equal(t, len(data2), n, "failed to read full data")

Expand All @@ -56,7 +57,7 @@ func TestPCMBuffer(t *testing.T) {
_, _ = p.Write(data)
}()

n, err = pr.Read(data2)
n, err = io.ReadAtLeast(pr, data2, len(data2))
require.NoError(t, err)
require.Equal(t, len(data2), n, "failed to read full data")

Expand Down

0 comments on commit 80cc2c2

Please sign in to comment.