mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 10:07:02 +00:00
Started work on MIME parser
I'm hoping to mostly rely on the official mime and mime/multipart packages, but Inbucket is still going to have to decided what to do with the various parts it reads.
This commit is contained in:
28
app/inbucket/mime_test.go
Normal file
28
app/inbucket/mime_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package inbucket
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"net/mail"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSomething(t *testing.T) {
|
||||
// Open test email for parsing
|
||||
raw, err := os.Open("../../test-data/html-mime-attach.raw")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to open test data: %v", err)
|
||||
}
|
||||
|
||||
// Parse email into a mail.Message object like we do
|
||||
reader := bufio.NewReader(raw)
|
||||
msg, err := mail.ReadMessage(reader)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to read message: %v", err)
|
||||
}
|
||||
|
||||
_, err = ParseMIMEMessage(msg)
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to parse mime: %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user