github.com/grafana/pyroscope@v1.18.0/pkg/objstore/read_only_file_test.go (about) 1 package objstore_test 2 3 import ( 4 "context" 5 "io" 6 "testing" 7 8 "github.com/stretchr/testify/mock" 9 "github.com/stretchr/testify/require" 10 11 "github.com/grafana/pyroscope/pkg/objstore" 12 "github.com/grafana/pyroscope/pkg/test/mocks/mockobjstore" 13 ) 14 15 func TestReadOnlyFileError(t *testing.T) { 16 m := new(mockobjstore.MockBucket) 17 m.EXPECT().Get(mock.Anything, "test").Return(failReader{}, nil).Once() 18 _, err := objstore.Download(context.Background(), "test", m, t.TempDir()) 19 require.ErrorIs(t, err, io.ErrNoProgress) 20 } 21 22 type failReader struct{} 23 24 func (failReader) Read([]byte) (int, error) { return 0, io.ErrNoProgress } 25 func (failReader) Close() error { return nil }