MCPcopy
hub / github.com/rs/zerolog / TestNewWriter

Function TestNewWriter

diode/diode_test.go:19–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestNewWriter(t *testing.T) {
20 buf := bytes.Buffer{}
21 w := diode.NewWriter(&buf, 1000, 0, func(missed int) {
22 fmt.Printf("Dropped %d messages\n", missed)
23 })
24 log := zerolog.New(w)
25 log.Print("test")
26
27 w.Close()
28 want := "{\"level\":\"debug\",\"message\":\"test\"}\n"
29 got := cbor.DecodeIfBinaryToString(buf.Bytes())
30 if got != want {
31 t.Errorf("Diode New Writer Test failed. got:%s, want:%s!", got, want)
32 }
33}
34
35func TestClose(t *testing.T) {
36 buf := bytes.Buffer{}

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
NewWriterFunction · 0.92
NewFunction · 0.92
DecodeIfBinaryToStringFunction · 0.92
PrintfMethod · 0.80
PrintMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected