} }) Describe("SetOnConnectCallback", func() { BeforeEach(func() { testServer = httptest.NewServer(handlers.NewWebsocketHandler(messagesToSend, 100*time.Millisecond)) endpoint = "ws://" + testServer.Listener.Addr().String() close(messagesToSend) }) It("sets a callback and calls it when connecting", func() { called := false cb := func() { called = true } connection = consumer.New(endpoint, tlsSettings, nil) connection.SetOnConnectCallback(cb) connection.Tail(appGuid, authToken) Eventually(func() bool { return called }).Should(BeTrue()) }) Context("when the connection fails", func() { It("does not call the callback", func() { endpoint = "!!!bad-endpoint" called := false cb := func() { called = true } connection = consumer.New(endpoint, tlsSettings, nil) connection.SetOnConnectCallback(cb) connection.Tail(appGuid, authToken)