MCPcopy
hub / github.com/nats-io/nats.go / TestFlush

Function TestFlush

test/basic_test.go:508–532  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

506}
507
508func TestFlush(t *testing.T) {
509 s := RunDefaultServer()
510 defer s.Shutdown()
511 nc := NewDefaultConnection(t)
512 defer nc.Close()
513
514 omsg := []byte("Hello World")
515 for i := 0; i < 10000; i++ {
516 nc.Publish("flush", omsg)
517 }
518 if err := nc.FlushTimeout(0); err == nil {
519 t.Fatal("Calling FlushTimeout() with invalid timeout should fail")
520 }
521 if err := nc.Flush(); err != nil {
522 t.Fatalf("Received error from flush: %s\n", err)
523 }
524 if nb, _ := nc.Buffered(); nb > 0 {
525 t.Fatalf("Outbound buffer not empty: %d bytes\n", nb)
526 }
527
528 nc.Close()
529 if _, err := nc.Buffered(); err == nil {
530 t.Fatal("Calling Buffered() on closed connection should fail")
531 }
532}
533
534func TestQueueSubscriber(t *testing.T) {
535 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 8

FatalfMethod · 0.80
BufferedMethod · 0.80
RunDefaultServerFunction · 0.70
NewDefaultConnectionFunction · 0.70
PublishMethod · 0.65
CloseMethod · 0.45
FlushTimeoutMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected