mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Add tests for nil SendError MessageID and Msg
These tests ensure that accessing MessageID and Msg methods on a nil SendError pointer returns the expected values (empty string and nil respectively). This helps in validating the error handling logic and avoiding potential nil pointer dereference issues.
This commit is contained in:
parent
77920be1a1
commit
52061f97c6
1 changed files with 14 additions and 0 deletions
|
@ -108,6 +108,13 @@ func TestSendError_MessageID(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSendError_MessageIDNil(t *testing.T) {
|
||||||
|
var se *SendError
|
||||||
|
if se.MessageID() != "" {
|
||||||
|
t.Error("expected empty string on nil-senderror")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestSendError_Msg(t *testing.T) {
|
func TestSendError_Msg(t *testing.T) {
|
||||||
var se *SendError
|
var se *SendError
|
||||||
err := returnSendError(ErrAmbiguous, false)
|
err := returnSendError(ErrAmbiguous, false)
|
||||||
|
@ -131,6 +138,13 @@ func TestSendError_Msg(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSendError_MsgNil(t *testing.T) {
|
||||||
|
var se *SendError
|
||||||
|
if se.Msg() != nil {
|
||||||
|
t.Error("expected nil on nil-senderror")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// returnSendError is a helper method to retunr a SendError with a specific reason
|
// returnSendError is a helper method to retunr a SendError with a specific reason
|
||||||
func returnSendError(r SendErrReason, t bool) error {
|
func returnSendError(r SendErrReason, t bool) error {
|
||||||
message := NewMsg()
|
message := NewMsg()
|
||||||
|
|
Loading…
Reference in a new issue