peterstace / simplefeatures

Simple Features is a pure Go Implementation of the OpenGIS Simple Feature Access Specification
MIT License
130 stars 19 forks source link

Better error assertions in tests #616

Closed peterstace closed 4 months ago

peterstace commented 4 months ago

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:

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:

Related Issue

peterstace commented 4 months ago

Thanks for reviewing!