88)
99
1010var _ = Describe ("AMQP Connection Test" , func () {
11- It ("AMQP SASLTypeAnonymous Connection should success " , func () {
11+ It ("AMQP SASLTypeAnonymous Connection should succeed " , func () {
1212 amqpConnection := NewAmqpConnection ()
1313 Expect (amqpConnection ).NotTo (BeNil ())
1414 Expect (amqpConnection ).To (BeAssignableToTypeOf (& AmqpConnection {}))
@@ -17,11 +17,14 @@ var _ = Describe("AMQP Connection Test", func() {
1717 Expect (connectionSettings ).NotTo (BeNil ())
1818 connectionSettings .SaslMechanism (SaslMechanism {Type : Anonymous })
1919 Expect (connectionSettings ).To (BeAssignableToTypeOf (& ConnectionSettings {}))
20- err := amqpConnection .Open (context .TODO (), connectionSettings )
20+
21+ err := amqpConnection .Open (context .Background (), connectionSettings )
22+ Expect (err ).To (BeNil ())
23+ err = amqpConnection .Close (context .Background ())
2124 Expect (err ).To (BeNil ())
2225 })
2326
24- It ("AMQP SASLTypePlain Connection should success " , func () {
27+ It ("AMQP SASLTypePlain Connection should succeed " , func () {
2528 amqpConnection := NewAmqpConnection ()
2629 Expect (amqpConnection ).NotTo (BeNil ())
2730 Expect (amqpConnection ).To (BeAssignableToTypeOf (& AmqpConnection {}))
@@ -30,7 +33,10 @@ var _ = Describe("AMQP Connection Test", func() {
3033 Expect (connectionSettings ).NotTo (BeNil ())
3134 Expect (connectionSettings ).To (BeAssignableToTypeOf (& ConnectionSettings {}))
3235 connectionSettings .SaslMechanism (SaslMechanism {Type : Plain })
33- err := amqpConnection .Open (context .TODO (), connectionSettings )
36+
37+ err := amqpConnection .Open (context .Background (), connectionSettings )
38+ Expect (err ).To (BeNil ())
39+ err = amqpConnection .Close (context .Background ())
3440 Expect (err ).To (BeNil ())
3541 })
3642
@@ -42,12 +48,12 @@ var _ = Describe("AMQP Connection Test", func() {
4248 Expect (connectionSettings ).NotTo (BeNil ())
4349 Expect (connectionSettings ).To (BeAssignableToTypeOf (& ConnectionSettings {}))
4450 connectionSettings .Host ("localhost" ).Port (1234 )
45- err := amqpConnection .Open (context .TODO (), connectionSettings )
51+
52+ err := amqpConnection .Open (context .Background (), connectionSettings )
4653 Expect (err ).NotTo (BeNil ())
4754 })
4855
4956 It ("AMQP Connection should fail due of wrong host" , func () {
50-
5157 amqpConnection := NewAmqpConnection ()
5258 Expect (amqpConnection ).NotTo (BeNil ())
5359 Expect (amqpConnection ).To (BeAssignableToTypeOf (& AmqpConnection {}))
@@ -56,11 +62,12 @@ var _ = Describe("AMQP Connection Test", func() {
5662 Expect (connectionSettings ).NotTo (BeNil ())
5763 Expect (connectionSettings ).To (BeAssignableToTypeOf (& ConnectionSettings {}))
5864 connectionSettings .Host ("wronghost" ).Port (5672 )
59- err := amqpConnection .Open (context .TODO (), connectionSettings )
65+
66+ err := amqpConnection .Open (context .Background (), connectionSettings )
6067 Expect (err ).NotTo (BeNil ())
6168 })
6269
63- It ("AMQP Connection should fail due of context cancelled " , func () {
70+ It ("AMQP Connection should fail due to context cancellation " , func () {
6471 amqpConnection := NewAmqpConnection ()
6572 Expect (amqpConnection ).NotTo (BeNil ())
6673 ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Millisecond )
@@ -69,12 +76,12 @@ var _ = Describe("AMQP Connection Test", func() {
6976 Expect (err ).NotTo (BeNil ())
7077 })
7178
72- It ("AMQP Connection should receive events " , func () {
79+ It ("AMQP Connection should receive events" , func () {
7380 amqpConnection := NewAmqpConnection ()
7481 Expect (amqpConnection ).NotTo (BeNil ())
7582 ch := make (chan * StatusChanged , 1 )
7683 amqpConnection .NotifyStatusChange (ch )
77- err := amqpConnection .Open (context .TODO (), NewConnectionSettings ())
84+ err := amqpConnection .Open (context .Background (), NewConnectionSettings ())
7885 Expect (err ).To (BeNil ())
7986 recv := <- ch
8087 Expect (recv ).NotTo (BeNil ())
@@ -88,7 +95,6 @@ var _ = Describe("AMQP Connection Test", func() {
8895
8996 Expect (recv .From ).To (Equal (Open ))
9097 Expect (recv .To ).To (Equal (Closed ))
91-
9298 })
9399
94100 //It("AMQP TLS Connection should success with SASLTypeAnonymous ", func() {
@@ -103,8 +109,7 @@ var _ = Describe("AMQP Connection Test", func() {
103109 // })
104110 // Expect(connectionSettings).NotTo(BeNil())
105111 // Expect(connectionSettings).To(BeAssignableToTypeOf(&ConnectionSettings{}))
106- // err := amqpConnection.Open(context.TODO (), connectionSettings)
112+ // err := amqpConnection.Open(context.Background (), connectionSettings)
107113 // Expect(err).To(BeNil())
108114 //})
109-
110115})
0 commit comments