Skip to content

Commit

Permalink
Update content-type handling for FreeBSD in msgwriter test
Browse files Browse the repository at this point in the history
Adjusted the expected content-type header in msgwriter tests to account for FreeBSD by setting it to 'application/octet-stream' instead of 'text/plain'. This ensures compatibility and correct behavior across different operating systems.
  • Loading branch information
wneessen committed Nov 26, 2024
1 parent 75c0e33 commit f61da9c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion msgwriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,15 @@ func TestMsgWriter_addFiles(t *testing.T) {
if msgwriter.err != nil {
t.Errorf("msgWriter failed to write: %s", msgwriter.err)
}
ctExpect := fmt.Sprintf(`Content-Type: text/plain; charset=utf-8; name="%s"`, tt.expect)

var ctExpect string
cdExpect := fmt.Sprintf(`Content-Disposition: attachment; filename="%s"`, tt.expect)
switch runtime.GOOS {
case "freebsd":
ctExpect = fmt.Sprintf(`Content-Type: application/octet-stream; charset=utf-8; name="%s"`, tt.expect)
default:
ctExpect = fmt.Sprintf(`Content-Type: text/plain; charset=utf-8; name="%s"`, tt.expect)
}
if !strings.Contains(buffer.String(), ctExpect) {
t.Errorf("expected content-type: %q, got: %q", ctExpect, buffer.String())
}
Expand Down

0 comments on commit f61da9c

Please sign in to comment.