MCPcopy
hub / github.com/uber-go/zap / TestNopLogger

Function TestNopLogger

logger_test.go:1024–1043  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1022}
1023
1024func TestNopLogger(t *testing.T) {
1025 logger := NewNop()
1026
1027 t.Run("basic levels", func(t *testing.T) {
1028 logger.Debug("foo", String("k", "v"))
1029 logger.Info("bar", Int("x", 42))
1030 logger.Warn("baz", Strings("ks", []string{"a", "b"}))
1031 logger.Error("qux", Error(errors.New("great sadness")))
1032 })
1033
1034 t.Run("DPanic", func(t *testing.T) {
1035 logger.With(String("component", "whatever")).DPanic("stuff")
1036 })
1037
1038 t.Run("Panic", func(t *testing.T) {
1039 assert.Panics(t, func() {
1040 logger.Panic("great sadness")
1041 }, "Nop logger should still cause panics.")
1042 })
1043}
1044
1045func TestMust(t *testing.T) {
1046 t.Run("must without an error does not panic", func(t *testing.T) {

Callers

nothing calls this directly

Calls 12

NewNopFunction · 0.85
StringFunction · 0.85
IntFunction · 0.85
StringsFunction · 0.85
ErrorFunction · 0.85
WithMethod · 0.65
DebugMethod · 0.45
InfoMethod · 0.45
WarnMethod · 0.45
ErrorMethod · 0.45
DPanicMethod · 0.45
PanicMethod · 0.45

Tested by

no test coverage detected