Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

506 B
Raw Blame
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{}
)