36b3af2e3d
PR Check / Code Quality: Format (push) Failing after 1s
PR Check / Code Quality: Lint (darwin) (push) Failing after 0s
PR Check / Code Quality: Lint (freebsd) (push) Failing after 1s
PR Check / Code Quality: Lint (windows) (push) Failing after 1s
PR Check / Code Quality: Lint (linux) (push) Failing after 1s
PR Check / Security: Vulnerability Scan (push) Failing after 0s
Update Documentation / update-docs (push) Failing after 2s
PR Check / Code Quality: Vendor (push) Failing after 1s
PR Check / Code Quality: Coverage (push) Failing after 0s
PR Check / Tests: Unit (macos-latest) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04) (push) Has been cancelled
PR Check / Tests: Unit (ubuntu-24.04-arm) (push) Has been cancelled
PR Check / Tests: Unit (windows-latest) (push) Has been cancelled
28 lines
843 B
Go
28 lines
843 B
Go
package target
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
// Resolvers return these sentinels (sometimes wrapped with %w) so callers branch
|
|
// on errors.Is rather than matching message text. This pins that the wrapping is
|
|
// transparent and the sentinels stay distinct.
|
|
func TestSentinelErrors(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if errors.Is(ErrUnsupported, ErrSocketOwnerUnknown) {
|
|
t.Error("ErrUnsupported and ErrSocketOwnerUnknown must be distinct")
|
|
}
|
|
|
|
// Mirrors how ResolveFile wraps ErrUnsupported with context.
|
|
wrapped := fmt.Errorf("finding process by file is %w", ErrUnsupported)
|
|
if !errors.Is(wrapped, ErrUnsupported) {
|
|
t.Errorf("errors.Is should see ErrUnsupported through wrapping; got %q", wrapped)
|
|
}
|
|
if errors.Is(wrapped, ErrSocketOwnerUnknown) {
|
|
t.Error("wrapped ErrUnsupported must not match ErrSocketOwnerUnknown")
|
|
}
|
|
}
|