Fix typo / inconsistency for (*Msg).SetAttachments

This commit is contained in:
Alexander Setzer 2024-08-14 14:55:08 +02:00
parent 3e4d8e3acd
commit 7caf0b8e19
2 changed files with 12 additions and 5 deletions

11
msg.go
View file

@ -684,11 +684,18 @@ func (m *Msg) GetBoundary() string {
return m.boundary
}
// SetAttachements sets the attachements of the message.
func (m *Msg) SetAttachements(files []*File) {
// SetAttachments sets the attachments of the message.
func (m *Msg) SetAttachments(files []*File) {
m.attachments = files
}
// SetAttachements sets the attachments of the message.
//
// Deprecated: use SetAttachments instead.
func (m *Msg) SetAttachements(files []*File) {
m.SetAttachments(files)
}
// UnsetAllAttachments unset the attachments of the message.
func (m *Msg) UnsetAllAttachments() {
m.attachments = nil

View file

@ -1413,7 +1413,7 @@ func TestMsg_SetAttachments(t *testing.T) {
for _, f := range tt.files {
files = append(files, &File{Name: f})
}
m.SetAttachements(files)
m.SetAttachments(files)
if len(m.attachments) != len(files) {
t.Errorf("SetAttachements() failed. Number of attachments expected: %d, got: %d", len(files),
len(m.attachments))
@ -1448,7 +1448,7 @@ func TestMsg_UnsetAllAttachments(t *testing.T) {
for _, f := range tt.attachments {
files = append(files, &File{Name: f})
}
m.SetAttachements(files)
m.SetAttachments(files)
if len(m.attachments) != len(files) {
t.Errorf("SetAttachements() failed. Number of attachments expected: %d, got: %d", len(files),
@ -1610,7 +1610,7 @@ func TestMsg_UnsetAllParts(t *testing.T) {
for _, f := range tt.attachments {
attachments = append(attachments, &File{Name: f})
}
m.SetAttachements(attachments)
m.SetAttachments(attachments)
if len(m.attachments) != len(attachments) {
t.Errorf("SetAttachements() failed. Number of attachments files expected: %d, got: %d",
len(attachments), len(m.attachments))