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

Function TestFieldClashWithTime

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

Source from the content-addressed store, hash-verified

48}
49
50func TestFieldClashWithTime(t *testing.T) {
51 formatter := &JSONFormatter{}
52
53 b, err := formatter.Format(WithField("time", "right now!"))
54 if err != nil {
55 t.Fatal("Unable to format entry: ", err)
56 }
57
58 entry := make(map[string]interface{})
59 err = json.Unmarshal(b, &entry)
60 if err != nil {
61 t.Fatal("Unable to unmarshal formatted entry: ", err)
62 }
63
64 if entry["fields.time"] != "right now!" {
65 t.Fatal("fields.time not set to original time field")
66 }
67
68 if entry["time"] != "0001-01-01T00:00:00Z" {
69 t.Fatal("time field not set to current time, was: ", entry["time"])
70 }
71}
72
73func TestFieldClashWithMsg(t *testing.T) {
74 formatter := &JSONFormatter{}

Callers

nothing calls this directly

Calls 3

FormatMethod · 0.95
WithFieldFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected