예제 #1
0
func TestReadCloserReadAll(t *testing.T) {
	rc := awstesting.ReadCloser{Size: 5}
	b := make([]byte, 5)

	n, err := rc.Read(b)

	assert.Equal(t, err, io.EOF)
	assert.Equal(t, n, 5)
	assert.False(t, rc.Closed)
	assert.Equal(t, rc.Size, 0)
}
예제 #2
0
func TestReadCloserRead(t *testing.T) {
	rc := awstesting.ReadCloser{Size: 5}
	b := make([]byte, 2)

	n, err := rc.Read(b)

	assert.Nil(t, err)
	assert.Equal(t, n, 2)
	assert.False(t, rc.Closed)
	assert.Equal(t, rc.Size, 3)

	err = rc.Close()
	assert.Nil(t, err)
	n, err = rc.Read(b)
	assert.Equal(t, err, io.EOF)
	assert.Equal(t, n, 0)
}