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

Function TestMaxSubscriptionsExceeded

test/sub_test.go:1841–1871  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1839}
1840
1841func TestMaxSubscriptionsExceeded(t *testing.T) {
1842 conf := createConfFile(t, []byte(`
1843 listen: 127.0.0.1:-1
1844 max_subscriptions: 5
1845 `))
1846 defer os.Remove(conf)
1847 s, _ := RunServerWithConfig(conf)
1848 defer s.Shutdown()
1849
1850 ch := make(chan error)
1851 nc, err := nats.Connect(s.ClientURL(), nats.ErrorHandler(func(c *nats.Conn, s *nats.Subscription, err error) {
1852 ch <- err
1853 }))
1854 if err != nil {
1855 t.Fatalf("Error on connect: %v", err)
1856 }
1857 defer nc.Close()
1858
1859 for range 6 {
1860 s, err := nc.Subscribe("foo", func(_ *nats.Msg) {})
1861 if err != nil {
1862 t.Fatalf("Error subscribing: %v", err)
1863 }
1864 defer s.Unsubscribe()
1865 }
1866
1867 WaitOnChannel(t, ch, nats.ErrMaxSubscriptionsExceeded)
1868
1869 // wait for the server to process the SUBs
1870 time.Sleep(100 * time.Millisecond)
1871}
1872
1873func TestClosedHandlerOnConnectionClose(t *testing.T) {
1874 s := RunDefaultServer()

Callers

nothing calls this directly

Calls 9

WaitOnChannelFunction · 0.85
ConnectMethod · 0.80
ErrorHandlerMethod · 0.80
FatalfMethod · 0.80
UnsubscribeMethod · 0.80
createConfFileFunction · 0.70
RunServerWithConfigFunction · 0.70
SubscribeMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected