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

Method TestAs

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

Source from the content-addressed store, hash-verified

344}
345
346func (*functionSuite) TestAs(c *gc.C) {
347 baseError := &basicError{"I'm an error"}
348 testErrors := []error{
349 errors.Trace(baseError),
350 errors.Annotate(baseError, "annotation"),
351 errors.Wrap(baseError, errors.New("wrapper")),
352 errors.Mask(baseError),
353 }
354
355 for _, err := range testErrors {
356 bError := &basicError{}
357 val := errors.As(err, &bError)
358 c.Check(val, gc.Equals, true)
359 c.Check(bError.Reason, gc.Equals, "I'm an error")
360 }
361}
362
363func (*functionSuite) TestIs(c *gc.C) {
364 baseError := &basicError{"I'm an error"}

Callers

nothing calls this directly

Calls 7

TraceFunction · 0.92
AnnotateFunction · 0.92
WrapFunction · 0.92
NewFunction · 0.92
MaskFunction · 0.92
AsFunction · 0.92
CheckMethod · 0.45

Tested by

no test coverage detected