MCPcopy
hub / github.com/pkg/errors / TestWithMessagef

Function TestWithMessagef

errors_test.go:208–225  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

206}
207
208func TestWithMessagef(t *testing.T) {
209 tests := []struct {
210 err error
211 message string
212 want string
213 }{
214 {io.EOF, "read error", "read error: EOF"},
215 {WithMessagef(io.EOF, "read error without format specifier"), "client error", "client error: read error without format specifier: EOF"},
216 {WithMessagef(io.EOF, "read error with %d format specifier", 1), "client error", "client error: read error with 1 format specifier: EOF"},
217 }
218
219 for _, tt := range tests {
220 got := WithMessagef(tt.err, tt.message).Error()
221 if got != tt.want {
222 t.Errorf("WithMessage(%v, %q): got: %q, want %q", tt.err, tt.message, got, tt.want)
223 }
224 }
225}
226
227// errors.New, etc values are not expected to be compared by value
228// but the change in errors#27 made them incomparable. Assert that

Callers

nothing calls this directly

Calls 2

WithMessagefFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…