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

Better error assertions in tests #616

Merged
merged 1 commit into from
May 16, 2024
Merged

Commits on May 15, 2024

  1. Better error assertions in tests

    This change introduces better error assertions, prompted by a comment
    from Albert Teoh here:
    #615 (comment)
    
    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` 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.
    peterstace committed May 15, 2024
    Configuration menu
    Copy the full SHA
    36542f9 View commit details
    Browse the repository at this point in the history