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

Function TestIncreaseLevelTryDecrease

increase_level_test.go:42–66  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

40}
41
42func TestIncreaseLevelTryDecrease(t *testing.T) {
43 errorOut := &bytes.Buffer{}
44 opts := []Option{
45 ErrorOutput(zapcore.AddSync(errorOut)),
46 }
47 withLogger(t, WarnLevel, opts, func(logger *Logger, logs *observer.ObservedLogs) {
48 logger.Warn("original warn log")
49
50 debugLogger := logger.WithOptions(IncreaseLevel(DebugLevel))
51 debugLogger.Debug("ignored debug log")
52 debugLogger.Warn("increase level warn log")
53 debugLogger.Error("increase level error log")
54
55 assert.Equal(t, []observer.LoggedEntry{
56 newLoggedEntry(WarnLevel, "original warn log"),
57 newLoggedEntry(WarnLevel, "increase level warn log"),
58 newLoggedEntry(ErrorLevel, "increase level error log"),
59 }, logs.AllUntimed(), "unexpected logs")
60 assert.Equal(t,
61 "failed to IncreaseLevel: invalid increase level, as level \"info\" is allowed by increased level, but not by existing core\n",
62 errorOut.String(),
63 "unexpected error output",
64 )
65 })
66}
67
68func TestIncreaseLevel(t *testing.T) {
69 errorOut := &bytes.Buffer{}

Callers

nothing calls this directly

Calls 11

StringMethod · 0.95
AddSyncFunction · 0.92
ErrorOutputFunction · 0.85
IncreaseLevelFunction · 0.85
newLoggedEntryFunction · 0.85
AllUntimedMethod · 0.80
withLoggerFunction · 0.70
WarnMethod · 0.45
WithOptionsMethod · 0.45
DebugMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected