mirror of https://codeberg.org/forgejo/forgejo.git
added test for reading inline attachments
This commit is contained in:
parent
b796694cd5
commit
85360b9db3
|
@ -95,6 +95,32 @@ func TestGetContentFromMailReader(t *testing.T) {
|
|||
assert.Equal(t, "attachment.txt", content.Attachments[0].Name)
|
||||
assert.Equal(t, []byte("attachment content"), content.Attachments[0].Content)
|
||||
|
||||
mailString = "Content-Type: multipart/mixed; boundary=message-boundary\r\n" +
|
||||
"\r\n" +
|
||||
"--message-boundary\r\n" +
|
||||
"Content-Type: multipart/alternative; boundary=text-boundary\r\n" +
|
||||
"\r\n" +
|
||||
"--text-boundary\r\n" +
|
||||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Disposition: inline\r\n" +
|
||||
"\r\n" +
|
||||
"mail content\r\n" +
|
||||
"--text-boundary--\r\n" +
|
||||
"--message-boundary\r\n" +
|
||||
"Content-Type: text/plain\r\n" +
|
||||
"Content-Disposition: inline; filename=attachment.txt\r\n" +
|
||||
"\r\n" +
|
||||
"attachment content\r\n" +
|
||||
"--message-boundary--\r\n"
|
||||
|
||||
env, err = enmime.ReadEnvelope(strings.NewReader(mailString))
|
||||
assert.NoError(t, err)
|
||||
content = getContentFromMailReader(env)
|
||||
assert.Equal(t, "mail content", content.Content)
|
||||
assert.Len(t, content.Attachments, 1)
|
||||
assert.Equal(t, "attachment.txt", content.Attachments[0].Name)
|
||||
assert.Equal(t, []byte("attachment content"), content.Attachments[0].Content)
|
||||
|
||||
mailString = "Content-Type: multipart/mixed; boundary=message-boundary\r\n" +
|
||||
"\r\n" +
|
||||
"--message-boundary\r\n" +
|
||||
|
|
Loading…
Reference in New Issue