diff --git a/internal/assertions/assertions.go b/internal/assertions/assertions.go index fa24d0f..53e8f17 100644 --- a/internal/assertions/assertions.go +++ b/internal/assertions/assertions.go @@ -959,11 +959,16 @@ func FileExistsFS(system fs.FS, file string) (s string) { func FileNotExistsFS(system fs.FS, file string) (s string) { _, err := fs.Stat(system, file) - if !errors.Is(err, fs.ErrNotExist) { + if err == nil { s = "expected file to not exist\n" s += bullet("name: %s\n", file) return } + if !errors.Is(err, fs.ErrNotExist) { + s = "expected not existing file but got different error\n" + s += bullet("error: %s\n", err) + return + } return } diff --git a/must/must.go b/must/must.go index 3fb4056..67d2199 100644 --- a/must/must.go +++ b/must/must.go @@ -5,6 +5,7 @@ package must import ( "io/fs" "os" + "path/filepath" "regexp" "strings" @@ -521,7 +522,9 @@ func FileNotExistsFS(t T, system fs.FS, file string, settings ...Setting) { // FileNotExists asserts file does not exist on the OS filesystem. func FileNotExists(t T, file string, settings ...Setting) { t.Helper() - invoke(t, assertions.FileNotExistsFS(os.DirFS(brokenfs.Root), file), settings...) + dir := filepath.Dir(file) + file = filepath.Base(file) + invoke(t, assertions.FileNotExistsFS(os.DirFS(dir), file), settings...) } // DirExistsFS asserts directory exists on the fs.FS filesystem. diff --git a/test.go b/test.go index 316abfc..4c97ef1 100644 --- a/test.go +++ b/test.go @@ -3,6 +3,7 @@ package test import ( "io/fs" "os" + "path/filepath" "regexp" "strings" @@ -519,7 +520,9 @@ func FileNotExistsFS(t T, system fs.FS, file string, settings ...Setting) { // FileNotExists asserts file does not exist on the OS filesystem. func FileNotExists(t T, file string, settings ...Setting) { t.Helper() - invoke(t, assertions.FileNotExistsFS(os.DirFS(brokenfs.Root), file), settings...) + dir := filepath.Dir(file) + file = filepath.Base(file) + invoke(t, assertions.FileNotExistsFS(os.DirFS(dir), file), settings...) } // DirExistsFS asserts directory exists on the fs.FS filesystem.