lib/readers: factor ErrorReader from multiple sources
This commit is contained in:
parent
36d2c46bcf
commit
cd3c699f28
6 changed files with 39 additions and 43 deletions
18
lib/readers/error_test.go
Normal file
18
lib/readers/error_test.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
package readers
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestErrorReader(t *testing.T) {
|
||||
errRead := errors.New("boom")
|
||||
r := ErrorReader{errRead}
|
||||
|
||||
buf := make([]byte, 16)
|
||||
n, err := r.Read(buf)
|
||||
assert.Equal(t, errRead, err)
|
||||
assert.Equal(t, 0, n)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue