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

Function TestEntryWithIncorrectField

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

Source from the content-addressed store, hash-verified

233}
234
235func TestEntryWithIncorrectField(t *testing.T) {
236 assert := assert.New(t)
237
238 fn := func() {}
239
240 e := Entry{Logger: New()}
241 eWithFunc := e.WithFields(Fields{"func": fn})
242 eWithFuncPtr := e.WithFields(Fields{"funcPtr": &fn})
243
244 assert.Equal(`can not add field "func"`, eWithFunc.err)
245 assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)
246
247 eWithFunc = eWithFunc.WithField("not_a_func", "it is a string")
248 eWithFuncPtr = eWithFuncPtr.WithField("not_a_func", "it is a string")
249
250 assert.Equal(`can not add field "func"`, eWithFunc.err)
251 assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)
252
253 eWithFunc = eWithFunc.WithTime(time.Now())
254 eWithFuncPtr = eWithFuncPtr.WithTime(time.Now())
255
256 assert.Equal(`can not add field "func"`, eWithFunc.err)
257 assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)
258}
259
260func TestEntryLogfLevel(t *testing.T) {
261 logger := New()

Callers

nothing calls this directly

Calls 4

WithFieldsMethod · 0.95
NewFunction · 0.85
WithFieldMethod · 0.65
WithTimeMethod · 0.45

Tested by

no test coverage detected