Skip to content

Commit 66ea3da

Browse files
committed
fix: make integration tests more quiet
1 parent 48b36c1 commit 66ea3da

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

integration_test.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,24 @@ func waitForHealthyAmqp(t *testing.T, connStr string) *Conn {
4040
defer cancel()
4141
tkr := time.NewTicker(time.Second)
4242

43+
// only log connection-level logs when verbose is enabled
44+
connLogger := simpleLogF(func(s string, i ...interface{}) {})
45+
if testing.Verbose() {
46+
connLogger = simpleLogF(t.Logf)
47+
}
48+
49+
var lastErr error
4350
for {
4451
select {
4552
case <-ctx.Done():
46-
t.Fatal("timed out waiting for healthy amqp", ctx.Err())
53+
t.Fatal("timed out waiting for healthy amqp", lastErr)
4754
return nil
4855
case <-tkr.C:
4956
t.Log("attempting connection")
50-
conn, err := NewConn(connStr, WithConnectionOptionsLogger(simpleLogF(t.Logf)))
57+
conn, err := NewConn(connStr, WithConnectionOptionsLogger(connLogger))
5158
if err != nil {
52-
t.Log("failed to connect", err.Error())
59+
lastErr = err
60+
t.Log("connection attempt failed - retrying")
5361
} else {
5462
if err := func() error {
5563
pub, err := NewPublisher(conn, WithPublisherOptionsLogger(simpleLogF(t.Logf)))

0 commit comments

Comments
 (0)