storj/pkg/ranger/readerat_test.go

36 lines
659 B
Go
Raw Normal View History

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package ranger
import (
"context"
2018-12-11 09:38:56 +00:00
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestRange(t *testing.T) {
2018-12-11 09:38:56 +00:00
for i, tt := range []struct {
offset int64
length int64
size int64
}{
2018-12-11 09:38:56 +00:00
{offset: -2, size: 0},
{offset: 2, length: -1, size: 0},
} {
2018-12-11 09:38:56 +00:00
tag := fmt.Sprintf("#%d. %+v", i, tt)
rr := readerAtRanger{size: tt.size}
closer, err := rr.Range(context.Background(), tt.offset, tt.length)
assert.Nil(t, closer, tag)
assert.NotNil(t, err, tag)
}
}
func TestClose(t *testing.T) {
rr := readerAtReader{length: 0}
assert.Nil(t, rr.Close())
}