-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
testing/fstest.TestFS
reports a single error which is the concatenation of all errors. This doesn't allow to analyze the errors by unwraping using errors.Is
or errors.As
or calling Unwrap() []error
.
See TestFS
code: https://github.com/golang/go/blob/master/src/testing/fstest/testfs.go#L107
Instead TestFS
should use errors.Join
or a custom error that implements the Unwrap() []error
method like errors.Join
.
What version of Go are you using (go version
)?
$ go version go version go1.21.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes, on master
branch.
Check code of the fsTester.errorf
method:
https://github.com/golang/go/blob/master/src/testing/fstest/testfs.go#L107
What did you do?
I'm testing a filesystem that enforces permissions: https://github.com/dolmen-go/sqlar
I applied TestFS to a filesystem that returns fs.ErrPermission
for ReadDir on multiple directories.
What did you expect to see?
I would like to analyze the errors using errors.Is
to ignore expected fs.ErrPermission
errors.
What did you see instead?
I got a big string containing the error messages concatenated.