Skip to content

Commit

Permalink
fix: skip test when not available
Browse files Browse the repository at this point in the history
  • Loading branch information
YC committed Jul 11, 2024
1 parent e931e61 commit 968440b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion services/mail/smtp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"net"
"net/http"
"testing"
"time"
Expand Down Expand Up @@ -49,11 +50,18 @@ func (suite *SmtpTestSuite) BeforeTest(suiteName, testName string) {
func TestSmtpTestSuite(t *testing.T) {
smtp4dev := newSmtp4DevClient()

address := net.JoinHostPort(Smtp4DevHost, fmt.Sprintf("%d", Smtp4DevPort))
_, err := net.DialTimeout("tcp", address, time.Second)
if err != nil {
t.Skipf("WARNING: smtp4Dev not available at %s - skipping smtp tests", address)
return
}

for i := 0; i < 5; i++ {
if smtp4dev.Check() == nil {
break
}
t.Logf("smtp4Dev not available at %s, retrying...", smtp4dev.ApiBaseUrl)
t.Logf("smtp4Dev not ready at %s, retrying...", smtp4dev.ApiBaseUrl)
time.Sleep(1 * time.Second)
}

Expand Down

0 comments on commit 968440b

Please sign in to comment.