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
Mohammed Al Sahaf 2026-08-30 18:39:17 +03:00
parent 9e6e892bd0
commit 07ae8c30a0
No known key found for this signature in database
1 changed files with 2 additions and 1 deletions

View File

@ -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