(t *testing.T)
| 480 | } |
| 481 | |
| 482 | func TestSlowChanSubscriber(t *testing.T) { |
| 483 | s := RunDefaultServer() |
| 484 | defer s.Shutdown() |
| 485 | |
| 486 | nc := NewDefaultConnection(t) |
| 487 | defer nc.Close() |
| 488 | |
| 489 | // Override default handler for test. |
| 490 | nc.SetErrorHandler(func(_ *nats.Conn, _ *nats.Subscription, _ error) {}) |
| 491 | |
| 492 | ch := make(chan *nats.Msg, 64) |
| 493 | sub, _ := nc.ChanSubscribe("foo", ch) |
| 494 | sub.SetPendingLimits(100, 1024) |
| 495 | |
| 496 | for range 200 { |
| 497 | nc.Publish("foo", []byte("Hello")) |
| 498 | } |
| 499 | timeout := 5 * time.Second |
| 500 | start := time.Now() |
| 501 | nc.FlushTimeout(timeout) |
| 502 | elapsed := time.Since(start) |
| 503 | if elapsed >= timeout { |
| 504 | t.Fatalf("Flush did not return before timeout: %d > %d", elapsed, timeout) |
| 505 | } |
| 506 | } |
| 507 | |
| 508 | func TestSlowAsyncSubscriber(t *testing.T) { |
| 509 | s := RunDefaultServer() |
nothing calls this directly
no test coverage detected