Skip to content

Commit

Permalink
Add test for closing a nil smtpclient
Browse files Browse the repository at this point in the history
Introduce a unit test to ensure that invoking Close on a nil smtpclient instance returns nil without errors. This enhances the robustness of the client closure functionality. This test accommodates the fix provided with PR #353
  • Loading branch information
wneessen committed Nov 6, 2024
1 parent 9ca7d24 commit a5fcb3a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,15 @@ func TestClient_Close(t *testing.T) {
t.Errorf("close was supposed to fail, but didn't")
}
})
t.Run("close on a nil smtpclient should return nil", func(t *testing.T) {
client, err := NewClient(DefaultHost)
if err != nil {
t.Fatalf("failed to create new client: %s", err)
}
if err = client.Close(); err != nil {
t.Errorf("failed to close the client: %s", err)
}
})
}

func TestClient_DialWithContext(t *testing.T) {
Expand Down

0 comments on commit a5fcb3a

Please sign in to comment.