Skip to content

Commit

Permalink
[chore] Give commonly failing test better message
Browse files Browse the repository at this point in the history
  • Loading branch information
kinbiko committed Sep 7, 2018
1 parent cc08d45 commit 8103ae6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bugsnag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,21 +246,24 @@ func TestAutoNotify(t *testing.T) {
ts, reports := setup()
defer ts.Close()

var panicked interface{}
var panicked error

func() {
defer func() {
panicked = recover()
p := recover()
switch p.(type) {
case error:
panicked = p.(error)
default:
t.Fatalf("Unexpected panic happened. Expected 'eggs' Error but was a(n) <%T> with value <%+v>", p, p)
}
}()
defer AutoNotify(Configuration{Endpoints: Endpoints{Notify: ts.URL}, APIKey: testAPIKey})

panic("eggs")
panic(fmt.Errorf("eggs"))
}()

// Note: If this line panics attempting to convert a `runtime.errorString`
// into `string` then comment out the `panicked = recover()` line above, as
// the panic you received here is not the one we expected.
if panicked.(string) != "eggs" {
if panicked.Error() != "eggs" {
t.Errorf("didn't re-panic")
}

Expand Down

0 comments on commit 8103ae6

Please sign in to comment.