Add option to panic in test.NewNullLogger to allow testing of

calls to `Fatal*`

See #813
This commit is contained in:
Albert Salim
2018-10-06 18:08:19 +08:00
parent 1ed61965b9
commit 2be620216a
5 changed files with 35 additions and 7 deletions
+11
View File
@@ -71,3 +71,14 @@ func TestLoggingWithHooksRace(t *testing.T) {
entries := hook.AllEntries()
assert.Equal(100, len(entries))
}
func TestFatalWithPanic(t *testing.T) {
assert := assert.New(t)
logger, hook := NewNullLogger(FatalPanics)
assert.Nil(hook.LastEntry())
assert.Equal(0, len(hook.Entries))
assert.Panics(func() { logger.Fatal("something went wrong") })
}