TestSpec_UsageExample_ErrorClassifiers validates that the documented usage example pattern compiles and runs. Specification (Usage Examples): if errorutil.IsNotFoundError(err) { ... } if errorutil.IsForbiddenError(err) { ... } if errorutil.IsGoneError(err) { ... }
(t *testing.T)
| 117 | // if errorutil.IsForbiddenError(err) { ... } |
| 118 | // if errorutil.IsGoneError(err) { ... } |
| 119 | func TestSpec_UsageExample_ErrorClassifiers(t *testing.T) { |
| 120 | notFound := errors.New("HTTP 404: Not Found") |
| 121 | forbidden := errors.New("HTTP 403: Forbidden") |
| 122 | gone := errors.New("HTTP 410: Gone") |
| 123 | |
| 124 | assert.True(t, errorutil.IsNotFoundError(notFound), "usage example: 404 path triggered") |
| 125 | assert.True(t, errorutil.IsForbiddenError(forbidden), "usage example: 403 path triggered") |
| 126 | assert.True(t, errorutil.IsGoneError(gone), "usage example: 410 path triggered") |
| 127 | |
| 128 | assert.False(t, errorutil.IsForbiddenError(notFound), "documented: classifiers are exclusive — 404 is not forbidden") |
| 129 | assert.False(t, errorutil.IsGoneError(notFound), "documented: classifiers are exclusive — 404 is not gone") |
| 130 | assert.False(t, errorutil.IsNotFoundError(forbidden), "documented: classifiers are exclusive — 403 is not not-found") |
| 131 | } |
nothing calls this directly
no test coverage detected