Skip to content

Commit

Permalink
fix: make integration tests more quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
astromechza committed Sep 5, 2024
1 parent 48b36c1 commit 66ea3da
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,24 @@ func waitForHealthyAmqp(t *testing.T, connStr string) *Conn {
defer cancel()
tkr := time.NewTicker(time.Second)

// only log connection-level logs when verbose is enabled
connLogger := simpleLogF(func(s string, i ...interface{}) {})
if testing.Verbose() {
connLogger = simpleLogF(t.Logf)
}

var lastErr error
for {
select {
case <-ctx.Done():
t.Fatal("timed out waiting for healthy amqp", ctx.Err())
t.Fatal("timed out waiting for healthy amqp", lastErr)
return nil
case <-tkr.C:
t.Log("attempting connection")
conn, err := NewConn(connStr, WithConnectionOptionsLogger(simpleLogF(t.Logf)))
conn, err := NewConn(connStr, WithConnectionOptionsLogger(connLogger))
if err != nil {
t.Log("failed to connect", err.Error())
lastErr = err
t.Log("connection attempt failed - retrying")
} else {
if err := func() error {
pub, err := NewPublisher(conn, WithPublisherOptionsLogger(simpleLogF(t.Logf)))
Expand Down

0 comments on commit 66ea3da

Please sign in to comment.