35 lines
688 B
Go
35 lines
688 B
Go
package iio_test
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"testing"
|
|
|
|
"git.kmsign.ru/royalcat/tstor/pkg/ioutils"
|
|
"git.kmsign.ru/royalcat/tstor/src/vfs"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
var testData []byte = []byte("Hello World")
|
|
|
|
func TestSeekerWrapper(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctx := context.Background()
|
|
require := require.New(t)
|
|
|
|
mf := vfs.NewMemoryFile("text.txt", testData)
|
|
|
|
r := ioutils.IoReadSeekCloserWrapper(ctx, mf, mf.Size())
|
|
defer r.Close()
|
|
|
|
n, err := r.Seek(6, io.SeekStart)
|
|
require.NoError(err)
|
|
require.Equal(int64(6), n)
|
|
|
|
toRead := make([]byte, 5)
|
|
nn, err := r.Read(toRead)
|
|
require.NoError(err)
|
|
require.Equal(5, nn)
|
|
require.Equal("World", string(toRead))
|
|
}
|