24 lines
389 B
Go
24 lines
389 B
Go
|
package mocks
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestReaderRead(t *testing.T) {
|
||
|
expected := errors.New("mocked error")
|
||
|
r := &Reader{
|
||
|
MockRead: func(b []byte) (int, error) {
|
||
|
return 0, expected
|
||
|
},
|
||
|
}
|
||
|
b := make([]byte, 128)
|
||
|
count, err := r.Read(b)
|
||
|
if !errors.Is(err, expected) {
|
||
|
t.Fatal("unexpected error", err)
|
||
|
}
|
||
|
if count != 0 {
|
||
|
t.Fatal("unexpected count", count)
|
||
|
}
|
||
|
}
|