MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / checkNextEntry

Method checkNextEntry

logger/formatter_json_test.go:298–322  ·  view source on GitHub ↗
(lvl string, msg map[string]any)

Source from the content-addressed store, hash-verified

296}
297
298func (s *FormatterJsonTestSuite) checkNextEntry(lvl string, msg map[string]any) {
299 str, err := s.buf().ReadString('\n')
300 s.Require().NoError(err)
301
302 var parsed map[string]any
303 err = json.Unmarshal([]byte(str), &parsed)
304 s.Require().NoError(err)
305
306 s.Require().IsType("", parsed["time"])
307 s.Require().IsType("", parsed["level"])
308
309 now := time.Now()
310 t, err := time.ParseInLocation(time.RFC3339, parsed["time"].(string), now.Location())
311 s.Require().NoError(err)
312 s.Require().WithinDuration(time.Now(), t, time.Minute)
313
314 s.Equal(lvl, parsed["level"].(string))
315
316 // Remove time and level as they are not included in `msg`
317 delete(parsed, "time")
318 delete(parsed, "level")
319
320 // Check the message
321 s.Equal(msg, parsed)
322}
323
324func TestFormatterJson(t *testing.T) {
325 suite.Run(t, new(FormatterJsonTestSuite))

Callers 4

TestLevelMethod · 0.95
TestAttributesMethod · 0.95
TestGroupsMethod · 0.95
TestEscapingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected