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

Function TestErrorNotLost

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

Source from the content-addressed store, hash-verified

10)
11
12func TestErrorNotLost(t *testing.T) {
13 formatter := &JSONFormatter{}
14
15 b, err := formatter.Format(WithField("error", errors.New("wild walrus")))
16 if err != nil {
17 t.Fatal("Unable to format entry: ", err)
18 }
19
20 entry := make(map[string]interface{})
21 err = json.Unmarshal(b, &entry)
22 if err != nil {
23 t.Fatal("Unable to unmarshal formatted entry: ", err)
24 }
25
26 if entry["error"] != "wild walrus" {
27 t.Fatal("Error field not set")
28 }
29}
30
31func TestErrorNotLostOnFieldNotNamedError(t *testing.T) {
32 formatter := &JSONFormatter{}

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.95
WithFieldFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected