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

Function TestDrainClosedHandlerRace

test/drain_test.go:498–516  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

496}
497
498func TestDrainClosedHandlerRace(t *testing.T) {
499 s := RunDefaultServer()
500 defer s.Shutdown()
501
502 nc, err := nats.Connect(s.ClientURL(), nats.ClosedHandler(func(_ *nats.Conn) {}))
503
504 if err != nil {
505 t.Fatalf("Unexpected error: %v", err)
506 }
507 defer nc.Close()
508
509 if err := nc.Drain(); err != nil {
510 t.Fatalf("Unexpected error on drain: %v", err)
511 }
512 go func() {
513 nc.SetClosedHandler(nil)
514 }()
515 time.Sleep(500 * time.Millisecond)
516}

Callers

nothing calls this directly

Calls 7

ConnectMethod · 0.80
ClosedHandlerMethod · 0.80
FatalfMethod · 0.80
RunDefaultServerFunction · 0.70
DrainMethod · 0.65
CloseMethod · 0.45
SetClosedHandlerMethod · 0.45

Tested by

no test coverage detected