mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-21 21:30:50 +01:00
Handle client close errors in SMTP tests
Update defer statements to log errors if client fails to close in smtp_test.go. Additionally, add a return statement to avoid further errors after a failed SendMail operation.
This commit is contained in:
parent
e2ed5b747a
commit
df1a141368
1 changed files with 11 additions and 2 deletions
|
@ -417,7 +417,11 @@ func TestXOAuth2OK(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("NewClient: %v", err)
|
||||
}
|
||||
defer c.Close()
|
||||
defer func() {
|
||||
if err := c.Close(); err != nil {
|
||||
t.Errorf("failed to close client: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
auth := XOAuth2Auth("user", "token")
|
||||
err = c.Auth(auth)
|
||||
|
@ -455,7 +459,11 @@ func TestXOAuth2Error(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("NewClient: %v", err)
|
||||
}
|
||||
defer c.Close()
|
||||
defer func() {
|
||||
if err := c.Close(); err != nil {
|
||||
t.Errorf("failed to close client: %s", err)
|
||||
}
|
||||
}()
|
||||
|
||||
auth := XOAuth2Auth("user", "token")
|
||||
err = c.Auth(auth)
|
||||
|
@ -1631,6 +1639,7 @@ SendMail is working for me.
|
|||
`, "\n", "\r\n", -1)))
|
||||
if err == nil {
|
||||
t.Error("SendMail: Server doesn't support AUTH, expected to get an error, but got none ")
|
||||
return
|
||||
}
|
||||
if err.Error() != "smtp: server doesn't support AUTH" {
|
||||
t.Errorf("Expected: smtp: server doesn't support AUTH, got: %s", err)
|
||||
|
|
Loading…
Reference in a new issue