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

Function TestErrorNotLostOnFieldNotNamedError

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

Source from the content-addressed store, hash-verified

29}
30
31func TestErrorNotLostOnFieldNotNamedError(t *testing.T) {
32 formatter := &JSONFormatter{}
33
34 b, err := formatter.Format(WithField("omg", errors.New("wild walrus")))
35 if err != nil {
36 t.Fatal("Unable to format entry: ", err)
37 }
38
39 entry := make(map[string]interface{})
40 err = json.Unmarshal(b, &entry)
41 if err != nil {
42 t.Fatal("Unable to unmarshal formatted entry: ", err)
43 }
44
45 if entry["omg"] != "wild walrus" {
46 t.Fatal("Error field not set")
47 }
48}
49
50func TestFieldClashWithTime(t *testing.T) {
51 formatter := &JSONFormatter{}

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.95
WithFieldFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected