mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Update test emails and enhance parser tests
The test emails in the eml_test.go file have been updated with more diverse fields, including variations of encoding types. These changes help improve the robustness of our parser tests by evaluating its function with a wider range of email structures. Tests including quoted-printable and base64 encoded emails have been added.
This commit is contained in:
parent
9607d08469
commit
8a1391b9df
1 changed files with 59 additions and 12 deletions
69
eml_test.go
69
eml_test.go
|
@ -10,23 +10,22 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
exampleMailPlainNoEnc = `Date: Thu, 14 Sep 2023 14:35:28 +0200
|
exampleMailPlainNoEnc = `Date: Wed, 01 Nov 2023 00:00:00 +0000
|
||||||
MIME-Version: 1.0
|
MIME-Version: 1.0
|
||||||
Message-ID:
|
Message-ID: <1305604950.683004066175.AAAAAAAAaaaaaaaaB@go-mail.dev>
|
||||||
<1305604950.683004066175.AAAAAAAAaaaaaaaaB@test.com>
|
Subject: Example mail // plain text without encoding
|
||||||
Subject: Example mail Plain text no Encoding
|
User-Agent: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
User-Agent: go-mail v0.3.9 // https://github.com/wneessen/go-mail
|
X-Mailer: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
X-Mailer: go-mail v0.3.8 // https://github.com/wneessen/go-mail
|
|
||||||
From: "Toni Tester" <go-mail@go-mail.dev>
|
From: "Toni Tester" <go-mail@go-mail.dev>
|
||||||
To: "Go Mail" <go-mail+test@go-mail.dev>
|
To: <go-mail+test@go-mail.dev>
|
||||||
Cc: Second Recipient <recipient@test.com>
|
Cc: <go-mail+cc@go-mail.dev>
|
||||||
Bcc: "Invisible User" <bcc@bcc.de>
|
|
||||||
Content-Type: text/plain; charset=UTF-8
|
Content-Type: text/plain; charset=UTF-8
|
||||||
Content-Transfer-Encoding: 8bit
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
Dear Customer,
|
Dear Customer,
|
||||||
|
|
||||||
This is a test mail. Please do not reply to this.
|
This is a test mail. Please do not reply to this. Also this line is very long so it
|
||||||
|
should be wrapped.
|
||||||
|
|
||||||
|
|
||||||
Thank your for your business!
|
Thank your for your business!
|
||||||
|
@ -34,6 +33,46 @@ The go-mail team
|
||||||
|
|
||||||
--
|
--
|
||||||
This is a signature`
|
This is a signature`
|
||||||
|
exampleMailPlainQP = `Date: Wed, 01 Nov 2023 00:00:00 +0000
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Message-ID: <1305604950.683004066175.AAAAAAAAaaaaaaaaB@go-mail.dev>
|
||||||
|
Subject: Example mail // plain text quoted-printable
|
||||||
|
User-Agent: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
|
X-Mailer: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
|
From: "Toni Tester" <go-mail@go-mail.dev>
|
||||||
|
To: <go-mail+test@go-mail.dev>
|
||||||
|
Cc: <go-mail+cc@go-mail.dev>
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: quoted-printable
|
||||||
|
|
||||||
|
Dear Customer,
|
||||||
|
|
||||||
|
This is a test mail. Please do not reply to this. Also this line is very lo=
|
||||||
|
ng so it
|
||||||
|
should be wrapped.
|
||||||
|
|
||||||
|
|
||||||
|
Thank your for your business!
|
||||||
|
The go-mail team
|
||||||
|
|
||||||
|
--
|
||||||
|
This is a signature`
|
||||||
|
exampleMailPlainB64 = `Date: Wed, 01 Nov 2023 00:00:00 +0000
|
||||||
|
MIME-Version: 1.0
|
||||||
|
Message-ID: <1305604950.683004066175.AAAAAAAAaaaaaaaaB@go-mail.dev>
|
||||||
|
Subject: Example mail // plain text base64
|
||||||
|
User-Agent: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
|
X-Mailer: go-mail v0.4.0 // https://github.com/wneessen/go-mail
|
||||||
|
From: "Toni Tester" <go-mail@go-mail.dev>
|
||||||
|
To: <go-mail+test@go-mail.dev>
|
||||||
|
Cc: <go-mail+cc@go-mail.dev>
|
||||||
|
Content-Type: text/plain; charset=UTF-8
|
||||||
|
Content-Transfer-Encoding: base64
|
||||||
|
|
||||||
|
RGVhciBDdXN0b21lciwKClRoaXMgaXMgYSB0ZXN0IG1haWwuIFBsZWFzZSBkbyBub3QgcmVwbHkg
|
||||||
|
dG8gdGhpcy4gQWxzbyB0aGlzIGxpbmUgaXMgdmVyeSBsb25nIHNvIGl0CnNob3VsZCBiZSB3cmFw
|
||||||
|
cGVkLgoKClRoYW5rIHlvdXIgZm9yIHlvdXIgYnVzaW5lc3MhClRoZSBnby1tYWlsIHRlYW0KCi0t
|
||||||
|
ClRoaXMgaXMgYSBzaWduYXR1cmU=`
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestEMLToMsgFromString(t *testing.T) {
|
func TestEMLToMsgFromString(t *testing.T) {
|
||||||
|
@ -45,7 +84,15 @@ func TestEMLToMsgFromString(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"Plain text no encoding", exampleMailPlainNoEnc, "8bit",
|
"Plain text no encoding", exampleMailPlainNoEnc, "8bit",
|
||||||
"Example mail Plain text no Encoding",
|
"Example mail // plain text without encoding",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Plain text quoted-printable", exampleMailPlainQP, "quoted-printable",
|
||||||
|
"Example mail // plain text quoted-printable",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Plain text base64", exampleMailPlainB64, "base64",
|
||||||
|
"Example mail // plain text base64",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
Loading…
Reference in a new issue