From 07ae8c30a0ffbac3b570a0ccec1ae4e2ef662bc3 Mon Sep 17 00:00:00 2001 From: Mohammed Al Sahaf Date: Sun, 30 Aug 2026 18:39:17 +0300 Subject: [PATCH] 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 --- filesystem_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/filesystem_test.go b/filesystem_test.go index ad295b55b..e9157f0e2 100644 --- a/filesystem_test.go +++ b/filesystem_test.go @@ -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