Add test for closing a nil smtpclient

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
This commit is contained in:
Winni Neessen 2024-11-06 10:47:31 +01:00
parent 9ca7d24f6a
commit a5fcb3ae8b
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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) {