mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:51:43 +00:00
Based on the [discussion in Slack](https://sourcegraph.slack.com/archives/C02UC4WUX1Q/p1717067410264679), thought it would be useful to solidify the invariants that hold between errors.As, errors.Is and errors.HasType (and provide counter-examples for things which you think ought to hold but don't actually hold) in code itself, instead of just via docs. So this PR adds property-based tests for quickly generating different kinds of error shapes, and check which invariants hold and which ones don't. It also adds better documentation for errors.Is and errors.As
41 lines
995 B
Python
41 lines
995 B
Python
load("//dev:go_defs.bzl", "go_test")
|
|
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
|
|
|
go_library(
|
|
name = "errors",
|
|
srcs = [
|
|
"cockroach.go",
|
|
"errors.go",
|
|
"filter.go",
|
|
"multi_error.go",
|
|
"postgres.go",
|
|
"warning.go",
|
|
],
|
|
importpath = "github.com/sourcegraph/sourcegraph/lib/errors",
|
|
tags = [TAG_INFRA_DEVINFRA],
|
|
visibility = ["//visibility:public"],
|
|
deps = [
|
|
"@com_github_cockroachdb_errors//:errors",
|
|
"@com_github_cockroachdb_redact//:redact",
|
|
"@com_github_jackc_pgconn//:pgconn",
|
|
],
|
|
)
|
|
|
|
go_test(
|
|
name = "errors_test",
|
|
timeout = "short",
|
|
srcs = [
|
|
"errors_test.go",
|
|
"filter_test.go",
|
|
"invariants_test.go",
|
|
"warning_test.go",
|
|
],
|
|
embed = [":errors"],
|
|
tags = [TAG_INFRA_DEVINFRA],
|
|
deps = [
|
|
"@com_github_stretchr_testify//assert",
|
|
"@com_github_stretchr_testify//require",
|
|
"@net_pgregory_rapid//:rapid",
|
|
],
|
|
)
|