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

Function TestFormatWithMessage

format_test.go:230–308  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

228}
229
230func TestFormatWithMessage(t *testing.T) {
231 tests := []struct {
232 error
233 format string
234 want []string
235 }{{
236 WithMessage(New("error"), "error2"),
237 "%s",
238 []string{"error2: error"},
239 }, {
240 WithMessage(New("error"), "error2"),
241 "%v",
242 []string{"error2: error"},
243 }, {
244 WithMessage(New("error"), "error2"),
245 "%+v",
246 []string{
247 "error",
248 "github.com/pkg/errors.TestFormatWithMessage\n" +
249 "\t.+/github.com/pkg/errors/format_test.go:244",
250 "error2"},
251 }, {
252 WithMessage(io.EOF, "addition1"),
253 "%s",
254 []string{"addition1: EOF"},
255 }, {
256 WithMessage(io.EOF, "addition1"),
257 "%v",
258 []string{"addition1: EOF"},
259 }, {
260 WithMessage(io.EOF, "addition1"),
261 "%+v",
262 []string{"EOF", "addition1"},
263 }, {
264 WithMessage(WithMessage(io.EOF, "addition1"), "addition2"),
265 "%v",
266 []string{"addition2: addition1: EOF"},
267 }, {
268 WithMessage(WithMessage(io.EOF, "addition1"), "addition2"),
269 "%+v",
270 []string{"EOF", "addition1", "addition2"},
271 }, {
272 Wrap(WithMessage(io.EOF, "error1"), "error2"),
273 "%+v",
274 []string{"EOF", "error1", "error2",
275 "github.com/pkg/errors.TestFormatWithMessage\n" +
276 "\t.+/github.com/pkg/errors/format_test.go:272"},
277 }, {
278 WithMessage(Errorf("error%d", 1), "error2"),
279 "%+v",
280 []string{"error1",
281 "github.com/pkg/errors.TestFormatWithMessage\n" +
282 "\t.+/github.com/pkg/errors/format_test.go:278",
283 "error2"},
284 }, {
285 WithMessage(WithStack(io.EOF), "error"),
286 "%+v",
287 []string{

Callers

nothing calls this directly

Calls 6

WithMessageFunction · 0.85
NewFunction · 0.85
WrapFunction · 0.85
ErrorfFunction · 0.85
WithStackFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…