diff --git a/msg_test.go b/msg_test.go index b09e514..20c44fd 100644 --- a/msg_test.go +++ b/msg_test.go @@ -19,6 +19,7 @@ import ( "net" "os" "reflect" + "runtime" "strings" "testing" ttpl "text/template" @@ -6056,6 +6057,10 @@ func TestMsg_WriteTo(t *testing.T) { if _, err := message.WriteTo(buffer); err != nil { t.Fatalf("failed to write message to buffer: %s", err) } + fileContentType := "text/plain" + if runtime.GOOS == "freebsd" { + fileContentType = "application/octet-stream" + } wants := []msgContentTest{ {0, "Date:", false, true, false}, {1, "MIME-Version: 1.0", true, true, false}, @@ -6090,7 +6095,7 @@ func TestMsg_WriteTo(t *testing.T) { {32, `Content-Disposition: inline; filename="embed.txt"`, true, true, false}, {33, "Content-Id: ", true, true, false}, {34, "Content-Transfer-Encoding: base64", true, true, false}, - {35, `Content-Type: text/plain; charset=utf-8; name="embed.txt"`, true, true, false}, + {35, `Content-Type: ` + fileContentType + `; charset=utf-8; name="embed.txt"`, true, true, false}, {36, "", true, false, false}, {37, "VGhp", false, true, false}, {38, "", true, false, false}, @@ -6099,7 +6104,7 @@ func TestMsg_WriteTo(t *testing.T) { {41, "--", false, true, false}, {42, `Content-Disposition: attachment; filename="attachment.txt"`, true, true, false}, {43, "Content-Transfer-Encoding: base64", true, true, false}, - {44, `Content-Type: text/plain; charset=utf-8; name="attachment.txt"`, true, true, false}, + {44, `Content-Type: ` + fileContentType + `; charset=utf-8; name="attachment.txt"`, true, true, false}, {45, "", true, false, false}, {46, "VGhp", false, true, false}, {47, "", true, false, false}, @@ -6123,6 +6128,10 @@ func TestMsg_WriteTo(t *testing.T) { if _, err := message.WriteTo(buffer); err != nil { t.Fatalf("failed to write message to buffer: %s", err) } + fileContentType := "text/plain" + if runtime.GOOS == "freebsd" { + fileContentType = "application/octet-stream" + } wants := []msgContentTest{ {0, "Date:", false, true, false}, {1, "MIME-Version: 1.0", true, true, false}, @@ -6164,7 +6173,7 @@ func TestMsg_WriteTo(t *testing.T) { {36, `Content-Disposition: inline; filename="embed.txt"`, true, true, false}, {37, "Content-Id: ", true, true, false}, {38, "Content-Transfer-Encoding: base64", true, true, false}, - {39, `Content-Type: text/plain; charset=utf-8; name="embed.txt"`, true, true, false}, + {39, `Content-Type: ` + fileContentType + `; charset=utf-8; name="embed.txt"`, true, true, false}, {40, "", true, false, false}, {41, "VGhp", false, true, false}, {42, "", true, false, false}, @@ -6173,7 +6182,7 @@ func TestMsg_WriteTo(t *testing.T) { {45, "--", false, true, false}, {46, `Content-Disposition: attachment; filename="attachment.txt"`, true, true, false}, {47, "Content-Transfer-Encoding: base64", true, true, false}, - {48, `Content-Type: text/plain; charset=utf-8; name="attachment.txt"`, true, true, false}, + {48, `Content-Type: ` + fileContentType + `; charset=utf-8; name="attachment.txt"`, true, true, false}, {49, "", true, false, false}, {50, "VGhp", false, true, false}, {51, "", true, false, false},