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

Function TestSubscribeSyncRace

test/nats_test.go:611–635  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

609}
610
611func TestSubscribeSyncRace(t *testing.T) {
612 s := RunServerOnPort(TEST_PORT)
613 defer s.Shutdown()
614
615 nc, err := nats.Connect(fmt.Sprintf("127.0.0.1:%d", TEST_PORT))
616 if err != nil {
617 t.Fatalf("Error on connect: %v", err)
618 }
619 defer nc.Close()
620
621 go func() {
622 time.Sleep(time.Millisecond)
623 nc.Close()
624 }()
625
626 subj := "foo.sync.race"
627 for i := 0; i < 10000; i++ {
628 if _, err := nc.SubscribeSync(subj); err != nil {
629 break
630 }
631 if _, err := nc.QueueSubscribeSync(subj, "gc"); err != nil {
632 break
633 }
634 }
635}
636
637func TestBadSubjectsAndQueueNames(t *testing.T) {
638 s := RunServerOnPort(TEST_PORT)

Callers

nothing calls this directly

Calls 6

ConnectMethod · 0.80
FatalfMethod · 0.80
RunServerOnPortFunction · 0.70
SubscribeSyncMethod · 0.65
QueueSubscribeSyncMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected