You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"testing/fstest"
)
funcmain() {
// Let's try to access file setup using relative path// This will work as expected.iferr:=testFS("mount/drive/file"); err!=nil {
panic(err)
}
// Now let's switch to an absolute path// This will fail with error 'file does not exist'iferr:=testFS("/mount/drive/file"); err!=nil {
panic(err)
}
}
functestFS(pathstring) error {
m:= fstest.MapFS{
path: {},
}
_, err:=m.ReadFile(path)
returnerr
}
What did you expect to see?
Judging from the documentation on testfs.MapFS, I'd expect any path present in the map to be treated as existing, regardless of containing the root directory or not.
What did you see instead?
When configuring paths and files with absolute paths including the root directory, any access to those will fail with file does not exist error messages.
I'm not 100% sure about the reason behind this, I suspect it derives from unclear definitions of what a root volume is on non unix systems (as discussed here #44279 ). Since the testing package requires explicit setup of file structures and hierarchies and essentially abstracts the real file system for tests, I don't really understand why it wouldn't work here either, though?
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
https://go.dev/play/p/psQhY3pZTkA
What did you expect to see?
Judging from the documentation on
testfs.MapFS
, I'd expect any path present in the map to be treated as existing, regardless of containing the root directory or not.What did you see instead?
When configuring paths and files with absolute paths including the root directory, any access to those will fail with
file does not exist
error messages.I'm not 100% sure about the reason behind this, I suspect it derives from unclear definitions of what a root volume is on non unix systems (as discussed here #44279 ). Since the testing package requires explicit setup of file structures and hierarchies and essentially abstracts the real file system for tests, I don't really understand why it wouldn't work here either, though?
The text was updated successfully, but these errors were encountered: