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

Function TestSpec_PublicAPI_IsGoneError

pkg/errorutil/spec_test.go:87–109  ·  view source on GitHub ↗

TestSpec_PublicAPI_IsGoneError validates the documented behavior of IsGoneError as described in the errorutil README.md. Specification: - Returns true when err indicates an HTTP-style 410/"gone" response by matching case-insensitive patterns like "HTTP 410" or "410 Gone". - Returns false for nil an

(t *testing.T)

Source from the content-addressed store, hash-verified

85// - Design note: requires HTTP-style status context so unrelated phrases
86// like "gone away" are not misclassified.
87func TestSpec_PublicAPI_IsGoneError(t *testing.T) {
88 tests := []struct {
89 name string
90 err error
91 want bool
92 }{
93 {name: "documented: nil returns false", err: nil, want: false},
94 {name: "documented: HTTP 410 pattern", err: errors.New("HTTP 410: Gone"), want: true},
95 {name: "documented: 410 Gone pattern", err: errors.New("410 Gone"), want: true},
96 {name: "documented: case-insensitive http 410", err: errors.New("http 410: gone"), want: true},
97 {name: "documented: case-insensitive HTTP 410 GONE", err: errors.New("HTTP 410: GONE"), want: true},
98 {name: "documented: wrapped HTTP 410", err: fmt.Errorf("api: %w", errors.New("HTTP 410: Gone")), want: true},
99 {name: "documented design note: 'gone away' is not misclassified", err: errors.New("connection has gone away"), want: false},
100 {name: "documented: non-matching error returns false", err: errors.New("totally unrelated"), want: false},
101 }
102
103 for _, tt := range tests {
104 t.Run(tt.name, func(t *testing.T) {
105 got := errorutil.IsGoneError(tt.err)
106 assert.Equal(t, tt.want, got, "IsGoneError(%v) mismatch for: %s", tt.err, tt.name)
107 })
108 }
109}
110
111// TestSpec_UsageExample_ErrorClassifiers validates that the documented usage
112// example pattern compiles and runs.

Callers

nothing calls this directly

Calls 3

IsGoneErrorFunction · 0.92
ErrorfMethod · 0.45
RunMethod · 0.45

Tested by

no test coverage detected