-
Notifications
You must be signed in to change notification settings - Fork 41
/
clientoptions_test.go
56 lines (51 loc) · 1.61 KB
/
clientoptions_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
package signalr
import (
"context"
"github.com/cenkalti/backoff/v4"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Client options", func() {
Describe("WithConnection and WithConnector option", func() {
Context("none of them is given", func() {
It("NewClient should fail", func() {
_, err := NewClient(context.TODO())
Expect(err).To(HaveOccurred())
}, 3.0)
})
Context("both are given", func() {
It("NewClient should fail", func() {
conn := NewNetConnection(context.TODO(), nil)
_, err := NewClient(context.TODO(), WithConnection(conn), WithConnector(func() (Connection, error) {
return conn, nil
}))
Expect(err).To(HaveOccurred())
}, 3.0)
})
Context("only WithConnection is given", func() {
It("NewClient should not fail", func() {
conn := NewNetConnection(context.TODO(), nil)
_, err := NewClient(context.TODO(), WithConnection(conn))
Expect(err).NotTo(HaveOccurred())
}, 3.0)
})
Context("only WithConnector is given", func() {
It("NewClient should not fail", func() {
conn := NewNetConnection(context.TODO(), nil)
_, err := NewClient(context.TODO(), WithConnector(func() (Connection, error) {
return conn, nil
}))
Expect(err).NotTo(HaveOccurred())
}, 3.0)
})
Context("only WithBackoff is given", func() {
It("NewClient should not fail", func() {
conn := NewNetConnection(context.TODO(), nil)
_, err := NewClient(context.TODO(), WithConnection(conn), WithBackoff(func() backoff.BackOff {
return backoff.NewExponentialBackOff()
}))
Expect(err).NotTo(HaveOccurred())
}, 3.0)
})
})
})