MCPcopy
hub / github.com/dropbox/godropbox / TestWrappedError

Function TestWrappedError

errors/errors_test.go:39–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

37}
38
39func TestWrappedError(t *testing.T) {
40 const (
41 innerMsg = "I am inner error"
42 middleMsg = "I am the middle error"
43 outerMsg = "I am the mighty outer error"
44 )
45 inner := fmt.Errorf(innerMsg)
46 middle := Wrap(inner, middleMsg)
47 outer := Wrap(middle, outerMsg)
48 errorStr := outer.Error()
49
50 if strings.Index(errorStr, innerMsg+"\n") == -1 {
51 t.Errorf("couldn't find inner error message in:\n%s", errorStr)
52 }
53
54 if strings.Index(errorStr, middleMsg+"\n") == -1 {
55 t.Errorf("couldn't find middle error message in:\n%s", errorStr)
56 }
57
58 if strings.Index(errorStr, outerMsg+"\n") == -1 {
59 t.Errorf("couldn't find outer error message in:\n%s", errorStr)
60 }
61}
62
63func TestRootErrors(t *testing.T) {
64 const (

Callers

nothing calls this directly

Calls 2

WrapFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected