github.com/philippseith/signalr@v0.6.3/clientoptions_test.go (about) 1 package signalr 2 3 import ( 4 "context" 5 "github.com/cenkalti/backoff/v4" 6 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("Client options", func() { 12 13 Describe("WithConnection and WithConnector option", func() { 14 Context("none of them is given", func() { 15 It("NewClient should fail", func() { 16 _, err := NewClient(context.TODO()) 17 Expect(err).To(HaveOccurred()) 18 }, 3.0) 19 }) 20 Context("both are given", func() { 21 It("NewClient should fail", func() { 22 conn := NewNetConnection(context.TODO(), nil) 23 _, err := NewClient(context.TODO(), WithConnection(conn), WithConnector(func() (Connection, error) { 24 return conn, nil 25 })) 26 Expect(err).To(HaveOccurred()) 27 }, 3.0) 28 }) 29 Context("only WithConnection is given", func() { 30 It("NewClient should not fail", func() { 31 conn := NewNetConnection(context.TODO(), nil) 32 _, err := NewClient(context.TODO(), WithConnection(conn)) 33 Expect(err).NotTo(HaveOccurred()) 34 }, 3.0) 35 }) 36 Context("only WithConnector is given", func() { 37 It("NewClient should not fail", func() { 38 conn := NewNetConnection(context.TODO(), nil) 39 _, err := NewClient(context.TODO(), WithConnector(func() (Connection, error) { 40 return conn, nil 41 })) 42 Expect(err).NotTo(HaveOccurred()) 43 }, 3.0) 44 }) 45 Context("only WithBackoff is given", func() { 46 It("NewClient should not fail", func() { 47 conn := NewNetConnection(context.TODO(), nil) 48 _, err := NewClient(context.TODO(), WithConnection(conn), WithBackoff(func() backoff.BackOff { 49 return backoff.NewExponentialBackOff() 50 })) 51 Expect(err).NotTo(HaveOccurred()) 52 }, 3.0) 53 }) 54 }) 55 56 })