MCPcopy
hub / github.com/pkg/errors / TestIs

Function TestIs

go113_test.go:20–72  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestIs(t *testing.T) {
21 err := New("test")
22
23 type args struct {
24 err error
25 target error
26 }
27 tests := []struct {
28 name string
29 args args
30 want bool
31 }{
32 {
33 name: "with stack",
34 args: args{
35 err: WithStack(err),
36 target: err,
37 },
38 want: true,
39 },
40 {
41 name: "with message",
42 args: args{
43 err: WithMessage(err, "test"),
44 target: err,
45 },
46 want: true,
47 },
48 {
49 name: "with message format",
50 args: args{
51 err: WithMessagef(err, "%s", "test"),
52 target: err,
53 },
54 want: true,
55 },
56 {
57 name: "std errors compatibility",
58 args: args{
59 err: fmt.Errorf("wrap it: %w", err),
60 target: err,
61 },
62 want: true,
63 },
64 }
65 for _, tt := range tests {
66 t.Run(tt.name, func(t *testing.T) {
67 if got := Is(tt.args.err, tt.args.target); got != tt.want {
68 t.Errorf("Is() = %v, want %v", got, tt.want)
69 }
70 })
71 }
72}
73
74type customErr struct {
75 msg string

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
WithStackFunction · 0.85
WithMessageFunction · 0.85
WithMessagefFunction · 0.85
IsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…