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

Function TestSamplerUnknownLevels

zapcore/sampler_test.go:272–290  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

270}
271
272func TestSamplerUnknownLevels(t *testing.T) {
273 // Prove that out-of-bounds levels don't panic.
274 unknownLevels := []Level{
275 DebugLevel - 1,
276 FatalLevel + 1,
277 }
278
279 for _, lvl := range unknownLevels {
280 t.Run(lvl.String(), func(t *testing.T) {
281 sampler, logs := fakeSampler(lvl, time.Minute, 2, 3)
282 for i := 1; i < 10; i++ {
283 writeSequence(sampler, i, lvl)
284 }
285
286 // Expect no sampling for unknown levels.
287 assertSequence(t, logs.TakeAll(), lvl, 1, 2, 3, 4, 5, 6, 7, 8, 9)
288 })
289 }
290}
291
292func TestSamplerWithZeroThereafter(t *testing.T) {
293 var counter countingCore

Callers

nothing calls this directly

Calls 5

fakeSamplerFunction · 0.85
writeSequenceFunction · 0.85
assertSequenceFunction · 0.85
TakeAllMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected