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

Function TestFieldDoesNotClashWithCaller

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

Source from the content-addressed store, hash-verified

269}
270
271func TestFieldDoesNotClashWithCaller(t *testing.T) {
272 SetReportCaller(false)
273 formatter := &JSONFormatter{}
274
275 b, err := formatter.Format(WithField("func", "howdy pardner"))
276 if err != nil {
277 t.Fatal("Unable to format entry: ", err)
278 }
279
280 entry := make(map[string]interface{})
281 err = json.Unmarshal(b, &entry)
282 if err != nil {
283 t.Fatal("Unable to unmarshal formatted entry: ", err)
284 }
285
286 if entry["func"] != "howdy pardner" {
287 t.Fatal("func field replaced when ReportCaller=false")
288 }
289}
290
291func TestFieldClashWithCaller(t *testing.T) {
292 SetReportCaller(true)

Callers

nothing calls this directly

Calls 4

FormatMethod · 0.95
SetReportCallerFunction · 0.85
WithFieldFunction · 0.85
FatalMethod · 0.65

Tested by

no test coverage detected