Skip to content

Commit

Permalink
Adjust file content type for FreeBSD in tests
Browse files Browse the repository at this point in the history
Introduced runtime-based file content type handling to account for differences in FreeBSD. This ensures tests correctly reflect platform-specific variations, switching from "text/plain" to "application/octet-stream" when necessary.
  • Loading branch information
wneessen committed Jan 19, 2025
1 parent 34077e9 commit b57dd96
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"net"
"os"
"reflect"
"runtime"
"strings"
"testing"
ttpl "text/template"
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -6090,7 +6095,7 @@ func TestMsg_WriteTo(t *testing.T) {
{32, `Content-Disposition: inline; filename="embed.txt"`, true, true, false},
{33, "Content-Id: <embed.txt>", 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},
Expand All @@ -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},
Expand All @@ -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},
Expand Down Expand Up @@ -6164,7 +6173,7 @@ func TestMsg_WriteTo(t *testing.T) {
{36, `Content-Disposition: inline; filename="embed.txt"`, true, true, false},
{37, "Content-Id: <embed.txt>", 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},
Expand All @@ -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},
Expand Down

0 comments on commit b57dd96

Please sign in to comment.