Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix FileExists assertion where relative paths did not work #149

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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