prog.go:18: TestFS found errors:
.: Open: open .: file does not exist
This may very well be a "works as intended" issue, and if so I apologise for the noise.
FYI: I ran into this while experimenting with implementing the opposite of fs.Sub, a Prefix(fs.FS, string) (fs.FS, error).
I provided a prefixFS.Sub as an optimisation where it returns another prefixFS with the prefix adjusted or calls fs.Sub on it's underlying file system to avoid chaining multiple wrappers. I ended up also implementing an EmptyFS that I return when the sub-dir isn't within my prefix in order to keep fstest.TestFS happy.
I imagine others implementing fs.SubFS and trying to test their code would appreciate not having to make their own EmptyFS just to satisfy fstest.TestFS. Perhaps an empty file system implementation could be provided or fstest could be tweaked with respect to what it accepts as a completely emtpy file system.
The text was updated successfully, but these errors were encountered:
changed the title
Should fs.Sub(fsys, "no such directory") return a file system that fails fstest.TestFS?Mar 17, 2021
@dchapes I think you can implement EmptyFS with fstest.MapFS with an empty map.
D'oh, you are indeed correct. Thanks for your comment!
I just verified that var fsys fstest.MapFS does indeed work correctly with fstest.TestFS as it implements a "." directory (as does var fsys embed.FS BTW). For some reason I had thought it wouldn't do that without even checking it. Oh well, I was just doing this all as an exercise with how the io/fs interfaces work in practice so my short time doing an EmptyFS wasn't wasted. If an empty file system turns out useful in practice I'd probably prefer one that didn't depend on somthing under testing/… anyway.