Skip to content

Commit

Permalink
Fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JenswBE committed Dec 13, 2023
1 parent 73bb970 commit c334435
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

"github.com/rs/zerolog/log"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)

Expand All @@ -31,7 +30,7 @@ func (s *E2ETestSuite) SetupSuite() {
// Server still down
if i >= 10 {
// Exceeded 10 tries => Fail unit tests
require.FailNow(s.T(), "Unable to contact SMTP mock server after 20 seconds")
s.Require().FailNow("Unable to contact SMTP mock server after 20 seconds")
}
// Retry in 2 seconds
log.Info().Err(err).Msg("Polling SMTP mock server failed, retrying in 2 seconds")
Expand All @@ -42,5 +41,5 @@ func (s *E2ETestSuite) SetupSuite() {

func (s *E2ETestSuite) SetupTest() {
err := clearMessages()
require.NoError(s.T(), err)
s.Require().NoError(err)
}
17 changes: 8 additions & 9 deletions test/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"

"github.com/jenswbe/smtp-cli/send"
"github.com/stretchr/testify/require"
)

func (s *E2ETestSuite) TestSendEmail() {
Expand All @@ -22,16 +21,16 @@ func (s *E2ETestSuite) TestSendEmail() {
BodyReader: bytes.NewBufferString("TestBody"),
AllowInsecureTLS: true,
})
require.NoError(s.T(), err)
s.Require().NoError(err)

// Validate email
messages, err := getMessages()
require.NoError(s.T(), err)
require.Len(s.T(), messages, 1, "Server should have received a single message")
require.Equal(s.T(), `"TestFromName" <TestFromAddress@example.com>`, messages[0].From)
require.Equal(s.T(), `"TestToName" <TestToAddress@example.com>`, messages[0].To)
require.Equal(s.T(), "TestSubject", messages[0].Subject)
s.Require().NoError(err)
s.Require().Len(messages, 1, "Server should have received a single message")
s.Require().Equal(`"TestFromName" <TestFromAddress@example.com>`, messages[0].From)
s.Require().Equal(`"TestToName" <TestToAddress@example.com>`, messages[0].To)
s.Require().Equal("TestSubject", messages[0].Subject)
messageBody, err := getMessageBody(messages[0].ID)
require.NoError(s.T(), err)
require.Contains(s.T(), messageBody, "TestBody")
s.Require().NoError(err)
s.Require().Contains(messageBody, "TestBody")
}

0 comments on commit c334435

Please sign in to comment.