TestSpec_PublicAPI_IsNotFoundError validates the documented behavior of IsNotFoundError as described in the errorutil README.md. Specification: - Returns true when err indicates a "not found" condition by matching case-insensitive "404" or "not found" text. - Returns false for nil and non-matching
(t *testing.T)
| 20 | // case-insensitive "404" or "not found" text. |
| 21 | // - Returns false for nil and non-matching errors. |
| 22 | func TestSpec_PublicAPI_IsNotFoundError(t *testing.T) { |
| 23 | tests := []struct { |
| 24 | name string |
| 25 | err error |
| 26 | want bool |
| 27 | }{ |
| 28 | {name: "documented: nil returns false", err: nil, want: false}, |
| 29 | {name: "documented: numeric 404 match", err: errors.New("HTTP 404: Not Found"), want: true}, |
| 30 | {name: "documented: lowercase not found", err: errors.New("not found"), want: true}, |
| 31 | {name: "documented: case-insensitive uppercase NOT FOUND", err: errors.New("RESOURCE NOT FOUND"), want: true}, |
| 32 | {name: "documented: case-insensitive mixed Not Found", err: errors.New("Resource Not Found"), want: true}, |
| 33 | {name: "documented: wrapped not found", err: fmt.Errorf("ctx: %w", errors.New("not found")), want: true}, |
| 34 | {name: "documented: non-matching error returns false", err: errors.New("something else went wrong"), want: false}, |
| 35 | } |
| 36 | |
| 37 | for _, tt := range tests { |
| 38 | t.Run(tt.name, func(t *testing.T) { |
| 39 | got := errorutil.IsNotFoundError(tt.err) |
| 40 | assert.Equal(t, tt.want, got, "IsNotFoundError(%v) mismatch for: %s", tt.err, tt.name) |
| 41 | }) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // TestSpec_PublicAPI_IsForbiddenError validates the documented behavior of |
| 46 | // IsForbiddenError as described in the errorutil README.md. |
nothing calls this directly
no test coverage detected