Implicitly discard the input to drain the reader

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Kazuyoshi Kato
2022-06-02 03:53:11 +00:00
committed by Derek McGowan
parent 49ca87d727
commit 40aa4f3f1b
2 changed files with 23 additions and 14 deletions

View File

@@ -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) {