(t *testing.T)
| 290 | } |
| 291 | |
| 292 | func TestSamplerWithZeroThereafter(t *testing.T) { |
| 293 | var counter countingCore |
| 294 | |
| 295 | // Logs two messages per second. |
| 296 | sampler := NewSamplerWithOptions(&counter, time.Second, 2, 0) |
| 297 | |
| 298 | now := time.Now() |
| 299 | |
| 300 | for i := 0; i < 1000; i++ { |
| 301 | ent := Entry{ |
| 302 | Level: InfoLevel, |
| 303 | Message: "msg", |
| 304 | Time: now, |
| 305 | } |
| 306 | if ce := sampler.Check(ent, nil); ce != nil { |
| 307 | ce.Write() |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | assert.Equal(t, 2, int(counter.logs.Load()), |
| 312 | "Unexpected number of logs") |
| 313 | |
| 314 | now = now.Add(time.Second) |
| 315 | |
| 316 | for i := 0; i < 1000; i++ { |
| 317 | ent := Entry{ |
| 318 | Level: InfoLevel, |
| 319 | Message: "msg", |
| 320 | Time: now, |
| 321 | } |
| 322 | if ce := sampler.Check(ent, nil); ce != nil { |
| 323 | ce.Write() |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | assert.Equal(t, 4, int(counter.logs.Load()), |
| 328 | "Unexpected number of logs") |
| 329 | } |
nothing calls this directly
no test coverage detected