mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-14 18:02:55 +01:00
Add tests for SendError functionalities
Introduce tests for `SendError` to verify behavior of `errors.Is` and string representation. `TestSendError_IsFail` checks for error mismatch, and `TestSendError_ErrorMulti` verifies the formatted error message.
This commit is contained in:
parent
52061f97c6
commit
f3633e1913
1 changed files with 18 additions and 0 deletions
|
@ -145,6 +145,24 @@ func TestSendError_MsgNil(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestSendError_IsFail(t *testing.T) {
|
||||
err1 := returnSendError(ErrAmbiguous, false)
|
||||
err2 := returnSendError(ErrSMTPMailFrom, false)
|
||||
if errors.Is(err1, err2) {
|
||||
t.Errorf("error mismatch, ErrAmbiguous should not be equal to ErrSMTPMailFrom")
|
||||
}
|
||||
}
|
||||
|
||||
func TestSendError_ErrorMulti(t *testing.T) {
|
||||
expected := `ambiguous reason, check Msg.SendError for message specific reasons, ` +
|
||||
`affected recipient(s): <email1@domain.tld>, <email2@domain.tld>`
|
||||
err := &SendError{Reason: ErrAmbiguous, isTemp: false, affectedMsg: nil,
|
||||
rcpt: []string{"<email1@domain.tld>", "<email2@domain.tld>"}}
|
||||
if err.Error() != expected {
|
||||
t.Errorf("error mismatch, expected: %s, got: %s", expected, err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
// returnSendError is a helper method to retunr a SendError with a specific reason
|
||||
func returnSendError(r SendErrReason, t bool) error {
|
||||
message := NewMsg()
|
||||
|
|
Loading…
Reference in a new issue