Update content-type handling for FreeBSD in msgwriter test

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.
This commit is contained in:
Winni Neessen 2024-11-26 16:34:09 +01:00
parent 75c0e3319b
commit f61da9cc2e
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -346,8 +346,15 @@ func TestMsgWriter_addFiles(t *testing.T) {
if msgwriter.err != nil { if msgwriter.err != nil {
t.Errorf("msgWriter failed to write: %s", msgwriter.err) 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) 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) { if !strings.Contains(buffer.String(), ctExpect) {
t.Errorf("expected content-type: %q, got: %q", ctExpect, buffer.String()) t.Errorf("expected content-type: %q, got: %q", ctExpect, buffer.String())
} }