(t *testing.T)
| 18 | } |
| 19 | |
| 20 | func 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 | |
| 74 | type customErr struct { |
| 75 | msg string |
nothing calls this directly
no test coverage detected
searching dependent graphs…