mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 14:40:49 +01:00
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:
parent
9ca7d24f6a
commit
a5fcb3ae8b
1 changed files with 9 additions and 0 deletions
|
@ -1647,6 +1647,15 @@ func TestClient_Close(t *testing.T) {
|
||||||
t.Errorf("close was supposed to fail, but didn'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) {
|
func TestClient_DialWithContext(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue