From 1ed8eef9ca7c1c889e9013eca9abee1507220782 Mon Sep 17 00:00:00 2001 From: Chef Date: Wed, 21 Feb 2024 22:23:59 +0700 Subject: [PATCH] CHORE add unittest for funtion Send for cover test coverage --- email_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/email_test.go b/email_test.go index b6d62d2..9d872b3 100644 --- a/email_test.go +++ b/email_test.go @@ -931,3 +931,24 @@ func TestParseSender(t *testing.T) { } } } + +func TestSendEmail(t *testing.T) { + input := &Email{ + From: "example_from@gmail.com", + To: []string{"example_to@gmail.com"}, + Subject: "Test Subject", + Text: []byte("This is a test email with HTML Formatting. It also has very long lines so\nthat the content must be wrapped if using quoted-printable decoding.\n"), + HTML: []byte("
This is a test email with HTML Formatting.\u00a0It also has very long lines so that the content must be wrapped if using quoted-printable decoding.
\n"), + } + + err := input.Send("smtp.gmail.com:587", smtp.PlainAuth("", input.From, "password123", "smtp.gmail.com")) + if err == nil { + t.Fatalf("Error expected when sending email") + } + + err = input.Send("smtp.gmail.com:587", smtp.PlainAuth("", input.From, "password123", "smtp.gmail.com")) + if err == nil { + t.Fatalf("Error expected when sending email") + } + +}