Implicitly discard the input to drain the reader
Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
committed by
Derek McGowan
parent
49ca87d727
commit
40aa4f3f1b
@@ -33,12 +33,15 @@ func TestCWWrite(t *testing.T) {
|
||||
assert.Equal(t, 5, n)
|
||||
|
||||
n, err = cw.Write([]byte("helloworld"))
|
||||
assert.Equal(t, []byte("hellohello"), buf.Bytes(), "partial write")
|
||||
assert.Equal(t, 5, n)
|
||||
assert.ErrorIs(t, err, errNoRemain)
|
||||
assert.NoError(t, err, "no errors even it hits the cap")
|
||||
assert.Equal(t, 10, n, "no indication of partial write")
|
||||
assert.True(t, cw.isFull())
|
||||
assert.Equal(t, []byte("hellohello"), buf.Bytes(), "the underlying writer is capped")
|
||||
|
||||
_, err = cw.Write([]byte("world"))
|
||||
assert.ErrorIs(t, err, errNoRemain)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, cw.isFull())
|
||||
assert.Equal(t, []byte("hellohello"), buf.Bytes(), "the underlying writer is capped")
|
||||
}
|
||||
|
||||
func TestCWClose(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user