Skip to content

MatchError cannot be used as is to ensure a particular sentinel error is returned. #876

@Smerom

Description

@Smerom

Due to MatchError performing a deep equality check after testing for errors.Is, certain mistakes can slip past it when a test is wanting to ensure that a particular sentinel error is returned. As a simple example

var SentinelError = errors.New("some error")

Expect(errors.New("some error")).To(MatchError(SentinelError)) // passes

errors.Is(errors.New("some error"), SentinelError) // returns false

Which means if a function should, but fails to return a sentinel error, but returns an error with the same underlying string value, MatchError will not catch the bug.

Related to #452 and #439

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions