mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-24 22:50:49 +01:00
Winni Neessen
31001e87b2
# SUMMARY * Bad licenses: * Deprecated licenses: * Licenses without file extension: * Missing licenses: * Unused licenses: * Used licenses: CC0-1.0, MIT * Read errors: 0 * Files with copyright information: 45 / 45 * Files with license information: 45 / 45 Congratulations! Your project is compliant with version 3.0 of the REUSE Specification :-)
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// SPDX-FileCopyrightText: 2022 Winni Neessen <winni@neessen.dev>
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package mail
|
|
|
|
import "testing"
|
|
|
|
// TestPartEncoding tests the WithPartEncoding and Part.SetEncoding methods
|
|
func TestPartEncoding(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
enc Encoding
|
|
want string
|
|
}{
|
|
{"Part encoding: Base64", EncodingB64, "base64"},
|
|
{"Part encoding: Quoted-Printable", EncodingQP, "quoted-printable"},
|
|
{"Part encoding: 8bit", NoEncoding, "8bit"},
|
|
}
|
|
for _, tt := range tests {
|
|
m := NewMsg()
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
part := m.newPart(TypeTextPlain, WithPartEncoding(tt.enc), nil)
|
|
if part == nil {
|
|
t.Errorf("newPart() WithPartEncoding() failed: no part returned")
|
|
return
|
|
}
|
|
if part.enc.String() != tt.want {
|
|
t.Errorf("newPart() WithPartEncoding() failed: expected encoding: %s, got: %s", tt.want,
|
|
part.enc.String())
|
|
}
|
|
part.enc = ""
|
|
part.SetEncoding(tt.enc)
|
|
if part.enc.String() != tt.want {
|
|
t.Errorf("newPart() SetEncoding() failed: expected encoding: %s, got: %s", tt.want,
|
|
part.enc.String())
|
|
}
|
|
})
|
|
}
|
|
}
|