These wrap errors.Is and errors.As functions from the standard library, respectively.
In order for this to work, the mismatchedGeometryCollectionDimsError must be exported, but only during tests (because we don't want to expose it to users of the library). This is achieved by using type aliases in a _test.go file in the geom package. Because _test.go files are only included during tests, this is a safe way to expose the type only during tests.
Check List
Have you:
Added unit tests? Yes.
Add cmprefimpl tests? (if appropriate?) N/A
Updated release notes? (if appropriate?) N/A (internal change, so probably doesn't need them).
Description
This change introduces better error assertions, prompted by a comment from Albert Teoh here: https://github.com/peterstace/simplefeatures/pull/615#discussion_r1601290941
The change introduces two new test helper functions:
expectErrIs(tb testing.TB, err, want error)
expectErrAs(tb testing.TB, err error, target interface{})
These wrap
errors.Is
anderrors.As
functions from the standard library, respectively.In order for this to work, the
mismatchedGeometryCollectionDimsError
must be exported, but only during tests (because we don't want to expose it to users of the library). This is achieved by using type aliases in a_test.go
file in thegeom
package. Because_test.go
files are only included during tests, this is a safe way to expose the type only during tests.Check List
Have you:
Added unit tests? Yes.
Add cmprefimpl tests? (if appropriate?) N/A
Updated release notes? (if appropriate?) N/A (internal change, so probably doesn't need them).
Related Issue