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

Function TestEntryPanicln

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

Source from the content-addressed store, hash-verified

129}
130
131func TestEntryPanicln(t *testing.T) {
132 errBoom := fmt.Errorf("boom time")
133
134 defer func() {
135 p := recover()
136 assert.NotNil(t, p)
137
138 switch pVal := p.(type) {
139 case *Entry:
140 assert.Equal(t, "kaboom", pVal.Message)
141 assert.Equal(t, errBoom, pVal.Data["err"])
142 default:
143 t.Fatalf("want type *Entry, got %T: %#v", pVal, pVal)
144 }
145 }()
146
147 logger := New()
148 logger.Out = &bytes.Buffer{}
149 entry := NewEntry(logger)
150 entry.WithField("err", errBoom).Panicln("kaboom")
151}
152
153func TestEntryPanicf(t *testing.T) {
154 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
PaniclnMethod · 0.65

Tested by

no test coverage detected