Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typo / inconsistency in Msg method #278

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,11 +684,18 @@
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)

Check warning on line 696 in msg.go

View check run for this annotation

Codecov / codecov/patch

msg.go#L695-L696

Added lines #L695 - L696 were not covered by tests
}

// UnsetAllAttachments unset the attachments of the message.
func (m *Msg) UnsetAllAttachments() {
m.attachments = nil
Expand Down Expand Up @@ -736,7 +743,7 @@
// The content type will be set to text/html automatically
func (m *Msg) SetBodyHTMLTemplate(tpl *ht.Template, data interface{}, opts ...PartOption) error {
if tpl == nil {
return fmt.Errorf(errTplPointerNil)

Check failure on line 746 in msg.go

View workflow job for this annotation

GitHub Actions / lint

SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
}
buffer := bytes.Buffer{}
if err := tpl.Execute(&buffer, data); err != nil {
Expand All @@ -751,7 +758,7 @@
// The content type will be set to text/plain automatically
func (m *Msg) SetBodyTextTemplate(tpl *tt.Template, data interface{}, opts ...PartOption) error {
if tpl == nil {
return fmt.Errorf(errTplPointerNil)

Check failure on line 761 in msg.go

View workflow job for this annotation

GitHub Actions / lint

SA1006: printf-style function with dynamic format string and no further arguments should use print-style function instead (staticcheck)
}
buf := bytes.Buffer{}
if err := tpl.Execute(&buf, data); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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))
Expand Down
Loading