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

Function TestNoFieldValueError

logger_test.go:31–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestNoFieldValueError(t *testing.T) {
32 buf := &bytes.Buffer{}
33 l := &Logger{
34 Out: buf,
35 Formatter: new(JSONFormatter),
36 Hooks: make(LevelHooks),
37 Level: DebugLevel,
38 }
39 l.WithField("str", "str").Info("test")
40 fmt.Println(buf.String())
41 var data map[string]interface{}
42 if err := json.Unmarshal(buf.Bytes(), &data); err != nil {
43 t.Error("unexpected error", err)
44 }
45 _, ok := data[FieldKeyLogrusError]
46 require.False(t, ok)
47}
48
49func TestWarninglnNotEqualToWarning(t *testing.T) {
50 buf := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 6

WithFieldMethod · 0.95
BytesMethod · 0.80
InfoMethod · 0.65
PrintlnMethod · 0.65
ErrorMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected