Skip to content

Commit 76b3ca6

Browse files
committed
Fix assertions running outside subject node
Because it can cause panics on failed assertions, and it does not respect the focus marker i.e. it always used to run.
1 parent c90b3b3 commit 76b3ca6

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

pkg/rabbitmqamqp/amqp_connection_test.go

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55
"crypto/tls"
66
"crypto/x509"
77
"fmt"
8+
"os"
9+
"time"
10+
811
"github.com/Azure/go-amqp"
912
. "github.com/onsi/ginkgo/v2"
1013
. "github.com/onsi/gomega"
11-
"os"
12-
"sync"
13-
"time"
1414
)
1515

1616
var _ = Describe("AMQP connection Test", func() {
@@ -117,12 +117,10 @@ var _ = Describe("AMQP connection Test", func() {
117117
})
118118

119119
Describe("AMQP TLS connection should succeed with in different vhosts with Anonymous and External.", func() {
120-
wg := &sync.WaitGroup{}
121-
wg.Add(4)
122120
DescribeTable("TLS connection should success in different vhosts ", func(virtualHost string, sasl amqp.SASLType) {
123121
// Load CA cert
124122
caCert, err := os.ReadFile("../../.ci/certs/ca_certificate.pem")
125-
Expect(err).To(BeNil())
123+
Expect(err).ToNot(HaveOccurred())
126124

127125
// Create a CA certificate pool and add the CA certificate to it
128126
caCertPool := x509.NewCertPool()
@@ -131,7 +129,7 @@ var _ = Describe("AMQP connection Test", func() {
131129
// Load client cert
132130
clientCert, err := tls.LoadX509KeyPair("../../.ci/certs/client_localhost_certificate.pem",
133131
"../../.ci/certs/client_localhost_key.pem")
134-
Expect(err).To(BeNil())
132+
Expect(err).ToNot(HaveOccurred())
135133

136134
// Create a TLS configuration
137135
tlsConfig := &tls.Config{
@@ -146,34 +144,32 @@ var _ = Describe("AMQP connection Test", func() {
146144
SASLType: sasl,
147145
TLSConfig: tlsConfig,
148146
})
149-
Expect(err).To(BeNil())
147+
Expect(err).ToNot(HaveOccurred())
150148
Expect(connection).NotTo(BeNil())
151149

152150
// Close the connection
153151
err = connection.Close(context.Background())
154-
Expect(err).To(BeNil())
155-
wg.Done()
152+
Expect(err).ToNot(HaveOccurred())
156153
},
157-
Entry("with virtual host. External", "%2F", amqp.SASLTypeExternal("")),
158-
Entry("with a not default virtual host. External", "tls", amqp.SASLTypeExternal("")),
159-
Entry("with virtual host. Anonymous", "%2F", amqp.SASLTypeAnonymous()),
160-
Entry("with a not default virtual host. Anonymous", "tls", amqp.SASLTypeAnonymous()),
154+
Entry("default virtual host + External", "%2F", amqp.SASLTypeExternal("")),
155+
Entry("non-default virtual host + External", "tls", amqp.SASLTypeExternal("")),
156+
Entry("default virtual host + Anonymous", "%2F", amqp.SASLTypeAnonymous()),
157+
Entry("non-default virtual host + Anonymous", "tls", amqp.SASLTypeAnonymous()),
161158
)
162-
go func() {
163-
wg.Wait()
164-
}()
165159
})
166160

167-
Describe("AMQP TLS connection should fail with error.", func() {
168-
tlsConfig := &tls.Config{}
161+
Describe("AMQP TLS connection", func() {
162+
It("should fail with error", func() {
163+
tlsConfig := &tls.Config{}
169164

170-
// Dial the AMQP server with TLS configuration
171-
connection, err := Dial(context.Background(), "amqps://does_not_exist:5671", &AmqpConnOptions{
172-
TLSConfig: tlsConfig,
165+
// Dial the AMQP server with TLS configuration
166+
connection, err := Dial(context.Background(), "amqps://does_not_exist:5671", &AmqpConnOptions{
167+
TLSConfig: tlsConfig,
168+
})
169+
Expect(connection).To(BeNil())
170+
Expect(err).To(HaveOccurred())
171+
Expect(err.Error()).To(ContainSubstring("failed to open TLS connection"))
173172
})
174-
Expect(connection).To(BeNil())
175-
Expect(err).To(HaveOccurred())
176-
Expect(err.Error()).To(ContainSubstring("failed to open TLS connection"))
177173
})
178174

179175
})

0 commit comments

Comments
 (0)