Merge pull request #278 from alfa-alex/main

Fix typo / inconsistency in Msg method
This commit is contained in:
Winni Neessen 2024-08-14 15:10:22 +02:00 committed by GitHub
commit 3311e4df77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 return m.boundary
} }
// SetAttachements sets the attachements of the message. // SetAttachments sets the attachments of the message.
func (m *Msg) SetAttachements(files []*File) { func (m *Msg) SetAttachments(files []*File) {
m.attachments = files 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. // UnsetAllAttachments unset the attachments of the message.
func (m *Msg) UnsetAllAttachments() { func (m *Msg) UnsetAllAttachments() {
m.attachments = nil m.attachments = nil

View file

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