Skip to content
This repository was archived by the owner on Dec 1, 2021. It is now read-only.

Commit abe54b4

Browse files
committed
Added more Stack tests
1 parent cc157cd commit abe54b4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

errors_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,21 @@ func TestStack(t *testing.T) {
208208
Cause(Wrap(New("ooh"), "ahh")), []fileline{
209209
{"github.com/pkg/errors/errors_test.go", 208}, // this is the stack of New
210210
},
211+
}, {
212+
func() error { return New("ooh") }(), []fileline{
213+
{"github.com/pkg/errors/errors_test.go", 212}, // this is the stack of New
214+
{"github.com/pkg/errors/errors_test.go", 212}, // this is the stack of New's caller
215+
},
216+
}, {
217+
Cause(func() error {
218+
return func() error {
219+
return Errorf("hello %s", fmt.Sprintf("world"))
220+
}()
221+
}()), []fileline{
222+
{"github.com/pkg/errors/errors_test.go", 219}, // this is the stack of Errorf
223+
{"github.com/pkg/errors/errors_test.go", 220}, // this is the stack of Errorf's caller
224+
{"github.com/pkg/errors/errors_test.go", 221}, // this is the stack of Errorf's caller's caller
225+
},
211226
}}
212227
for _, tt := range tests {
213228
x, ok := tt.err.(interface {

0 commit comments

Comments
 (0)