caddy: mockFile.Read should return io.EOF per io.Reader contract
The io.Reader contract says a Read at EOF returns io.EOF (0, io.EOF). The mock was returning fs.ErrClosed, which is a distinct sentinel used for reads on already-closed files. Aligning the mock with the stdlib contract keeps tests that iterate over the file happy. Signed-off-by: Mohammed Al Sahaf <msaa1990@gmail.com>add-tests
parent
9e6e892bd0
commit
07ae8c30a0
|
|
@ -16,6 +16,7 @@ package caddy
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"sync"
|
||||
"testing"
|
||||
|
|
@ -47,7 +48,7 @@ func (m *mockFile) Stat() (fs.FileInfo, error) {
|
|||
|
||||
func (m *mockFile) Read(b []byte) (int, error) {
|
||||
if m.pos >= len(m.content) {
|
||||
return 0, fs.ErrClosed
|
||||
return 0, io.EOF
|
||||
}
|
||||
n := copy(b, m.content[m.pos:])
|
||||
m.pos += n
|
||||
|
|
|
|||
Loading…
Reference in New Issue