mirror of
https://github.com/rclone/rclone.git
synced 2024-12-15 03:31:50 +01:00
32 lines
506 B
Go
32 lines
506 B
Go
package readers
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestNoSeeker(t *testing.T) {
|
|
r := bytes.NewBufferString("hello")
|
|
rs := NoSeeker{Reader: r}
|
|
|
|
// Check read
|
|
b := make([]byte, 4)
|
|
n, err := rs.Read(b)
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, 4, n)
|
|
assert.Equal(t, []byte("hell"), b)
|
|
|
|
// Check seek
|
|
_, err = rs.Seek(0, io.SeekCurrent)
|
|
assert.Equal(t, errCantSeek, err)
|
|
}
|
|
|
|
// check interfaces
|
|
var (
|
|
_ io.Reader = NoSeeker{}
|
|
_ io.Seeker = NoSeeker{}
|
|
)
|