MCPcopy Create free account
hub / github.com/github/gh-aw / TestSpec_UsageExample_ErrorClassifiers

Function TestSpec_UsageExample_ErrorClassifiers

pkg/errorutil/spec_test.go:119–131  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

117// if errorutil.IsForbiddenError(err) { ... }
118// if errorutil.IsGoneError(err) { ... }
119func 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}

Callers

nothing calls this directly

Calls 3

IsNotFoundErrorFunction · 0.92
IsForbiddenErrorFunction · 0.92
IsGoneErrorFunction · 0.92

Tested by

no test coverage detected