MCPcopy
hub / github.com/sirupsen/logrus / TestEntryPanicf

Function TestEntryPanicf

entry_test.go:153–173  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestEntryPanicf(t *testing.T) {
154 errBoom := fmt.Errorf("boom again")
155
156 defer func() {
157 p := recover()
158 assert.NotNil(t, p)
159
160 switch pVal := p.(type) {
161 case *Entry:
162 assert.Equal(t, "kaboom true", pVal.Message)
163 assert.Equal(t, errBoom, pVal.Data["err"])
164 default:
165 t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
166 }
167 }()
168
169 logger := New()
170 logger.Out = &bytes.Buffer{}
171 entry := NewEntry(logger)
172 entry.WithField("err", errBoom).Panicf("kaboom %v", true)
173}
174
175func TestEntryPanic(t *testing.T) {
176 errBoom := fmt.Errorf("boom again")

Callers

nothing calls this directly

Calls 6

WithFieldMethod · 0.95
NewFunction · 0.85
NewEntryFunction · 0.85
ErrorfMethod · 0.65
FatalfMethod · 0.65
PanicfMethod · 0.65

Tested by

no test coverage detected