MCPcopy Create free account
hub / github.com/juju/errors / TestFormat

Method TestFormat

functions_test.go:306–336  ·  view source on GitHub ↗
(c *gc.C)

Source from the content-addressed store, hash-verified

304}
305
306func (*functionSuite) TestFormat(c *gc.C) {
307 formatErrorExpected := &strings.Builder{}
308 err := errors.New("TestFormat")
309 fmt.Fprintf(formatErrorExpected, "%s: TestFormat\n", errorLocationValue(c))
310 err = errors.Mask(err)
311 fmt.Fprintf(formatErrorExpected, "%s: ", errorLocationValue(c))
312
313 for i, test := range []struct {
314 format string
315 expect string
316 }{{
317 format: "%s",
318 expect: "TestFormat",
319 }, {
320 format: "%v",
321 expect: "TestFormat",
322 }, {
323 format: "%q",
324 expect: `"TestFormat"`,
325 }, {
326 format: "%A",
327 expect: `%!A(*errors.Err=TestFormat)`,
328 }, {
329 format: "%+v",
330 expect: formatErrorExpected.String(),
331 }} {
332 c.Logf("test %d: %q", i, test.format)
333 s := fmt.Sprintf(test.format, err)
334 c.Check(s, gc.Equals, test.expect)
335 }
336}
337
338type basicError struct {
339 Reason string

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
MaskFunction · 0.92
errorLocationValueFunction · 0.85
CheckMethod · 0.45

Tested by

no test coverage detected