forked from jina-ai/client-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
websocket_test.go
60 lines (52 loc) · 1.64 KB
/
websocket_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package client
import (
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("Websocket Client", Ordered, func() {
var c *WebSocketClient
var hc *WebSocketHealthCheckClient
var err error
BeforeEach(func() {
cleanUp := startFlow("examples/websocket/flow.yml")
time.Sleep(2 * time.Second)
DeferCleanup(func() {
*c = WebSocketClient{}
cleanUp()
})
})
Describe("Create the Client and stream requests", func() {
It("should create a new WebSocketClient & stream requests", func() {
Eventually(func() error {
c, err = NewWebSocketClient("ws://localhost:12345")
return err
}, 10*time.Second, 1*time.Second).Should(BeNil())
Expect(c).NotTo(BeNil())
c.POST(generateDataRequests(3), OnDone, OnError, nil)
})
})
Describe("Create the Client and stream requests sequentially", func() {
It("should create a new WebSocketClient & stream requests", func() {
Eventually(func() error {
c, err = NewWebSocketClient("ws://localhost:12345")
return err
}, 10*time.Second, 1*time.Second).Should(BeNil())
Expect(c).NotTo(BeNil())
c.SequentialPOST(generateDataRequests(3), OnDone, OnError, nil)
})
})
Describe("Perform healthchecks on the client", func() {
It("should create a new WebSocketHealthCheckClient & perform a successful healthcheck", func() {
Eventually(func() error {
hc, err = NewWebSocketHealthCheckClient("ws://localhost:12345")
return err
}, 10*time.Second, 1*time.Second).Should(BeNil())
Expect(hc).NotTo(BeNil())
Eventually(func() bool {
status, _ := hc.HealthCheck()
return status
}, 10*time.Second, 1*time.Second).Should(BeTrue())
})
})
})