diff --git a/must/must.go b/must/must.go index ca976d6..4488e96 100644 --- a/must/must.go +++ b/must/must.go @@ -510,8 +510,9 @@ func FileExistsFS(t T, system fs.FS, file string, settings ...Setting) { // FileExists asserts file exists on the OS filesystem. func FileExists(t T, file string, settings ...Setting) { t.Helper() - file = strings.TrimPrefix(file, "/") - invoke(t, assertions.FileExistsFS(os.DirFS(brokenfs.Root), file), settings...) + dir := filepath.Dir(file) + file = filepath.Base(file) + invoke(t, assertions.FileExistsFS(os.DirFS(dir), file), settings...) } // FileNotExistsFS asserts file does not exist on the fs.FS filesystem. diff --git a/test.go b/test.go index 2723cd2..94b0481 100644 --- a/test.go +++ b/test.go @@ -508,8 +508,9 @@ func FileExistsFS(t T, system fs.FS, file string, settings ...Setting) { // FileExists asserts file exists on the OS filesystem. func FileExists(t T, file string, settings ...Setting) { t.Helper() - file = strings.TrimPrefix(file, "/") - invoke(t, assertions.FileExistsFS(os.DirFS(brokenfs.Root), file), settings...) + dir := filepath.Dir(file) + file = filepath.Base(file) + invoke(t, assertions.FileExistsFS(os.DirFS(dir), file), settings...) } // FileNotExistsFS asserts file does not exist on the fs.FS filesystem.