Skip to content

Commit

Permalink
Add test for WrapError function
Browse files Browse the repository at this point in the history
  • Loading branch information
flimzy committed Jun 8, 2020
1 parent 8394225 commit 31bb9a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,17 @@ func TestWriteError(t *testing.T) {
t.Errorf("did not get error on write. have=nil, want=some error")
}
}

func TestWrapError(t *testing.T) {
rootCause := errors.New("cause")
twerr := NewError(NotFound, "it ain't there")
err := WrapError(twerr, rootCause)
cause := errors.Cause(err)
if cause != rootCause {
t.Errorf("got wrong cause. got=%q, want=%q", cause, rootCause)
}
wantMsg := "twirp error not_found: it ain't there"
if gotMsg := err.Error(); gotMsg != wantMsg {
t.Errorf("got wrong error text. got=%q, want=%q", gotMsg, wantMsg)
}
}

0 comments on commit 31bb9a0

Please sign in to comment.