go-mail/part_test.go
Winni Neessen 31001e87b2
#24: Add SPDX license IDs for REUSE compliance
# 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 :-)
2022-06-17 15:05:54 +02:00

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())
}
})
}
}