(t *testing.T)
| 42 | ) |
| 43 | |
| 44 | func Test_isErrorCode(t *testing.T) { |
| 45 | type args struct { |
| 46 | err error |
| 47 | codes []string |
| 48 | } |
| 49 | tests := []struct { |
| 50 | name string |
| 51 | args args |
| 52 | want bool |
| 53 | }{ |
| 54 | { |
| 55 | name: "test wrapped pg error", |
| 56 | args: args{ |
| 57 | codes: []string{"42P01"}, |
| 58 | err: fmt.Errorf("foo: %w", |
| 59 | &pgErrorImplementation{ |
| 60 | sqlState: "42P01", |
| 61 | }, |
| 62 | ), |
| 63 | }, |
| 64 | want: true, |
| 65 | }, |
| 66 | { |
| 67 | name: "test wrapped legacy error", |
| 68 | args: args{ |
| 69 | codes: []string{"42P01"}, |
| 70 | err: fmt.Errorf("foo: %w", |
| 71 | &legacyPGErrorImplementation{ |
| 72 | err: errors.New("test"), |
| 73 | fatal: true, |
| 74 | codes: map[byte]string{ |
| 75 | 'C': "42P01", |
| 76 | }, |
| 77 | }, |
| 78 | ), |
| 79 | }, |
| 80 | want: true, |
| 81 | }, |
| 82 | } |
| 83 | for _, tt := range tests { |
| 84 | t.Run(tt.name, func(t *testing.T) { |
| 85 | if got := isErrorCode(tt.args.err, tt.args.codes...); got != tt.want { |
| 86 | t.Errorf("isErrorCode() = %v, want %v", got, tt.want) |
| 87 | } |
| 88 | }) |
| 89 | } |
| 90 | } |
nothing calls this directly
no test coverage detected