Skip to content

Commit

Permalink
test: fix FileExists assertion where relative paths did not work
Browse files Browse the repository at this point in the history
  • Loading branch information
shoenig committed Feb 29, 2024
1 parent 32c31d3 commit 6dcc2ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions must/must.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 6dcc2ce

Please sign in to comment.