mirror of
https://github.com/wneessen/go-mail.git
synced 2024-12-23 02:50:39 +01:00
Add test cases for AttachFromEmbedFS errors
Introduce two new test cases for the AttachFromEmbedFS method. These tests verify that the method correctly handles an invalid file path and a nil embed FS, ensuring error scenarios are properly managed.
This commit is contained in:
parent
e779777c9b
commit
d02f469658
1 changed files with 21 additions and 1 deletions
22
msg_test.go
22
msg_test.go
|
@ -4766,8 +4766,28 @@ func TestMsg_AttachFromEmbedFS(t *testing.T) {
|
|||
if !strings.EqualFold(got, "This is a test attachment") {
|
||||
t.Errorf("expected message body to be %s, got: %s", "This is a test attachment", got)
|
||||
}
|
||||
|
||||
})
|
||||
t.Run("AttachFromEmbedFS with invalid path", func(t *testing.T) {
|
||||
message := NewMsg()
|
||||
if message == nil {
|
||||
t.Fatal("message is nil")
|
||||
}
|
||||
err := message.AttachFromEmbedFS("testdata/invalid.txt", &efs, WithFileName("attachment.txt"))
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
})
|
||||
t.Run("AttachFromEmbedFS with nil embed FS", func(t *testing.T) {
|
||||
message := NewMsg()
|
||||
if message == nil {
|
||||
t.Fatal("message is nil")
|
||||
}
|
||||
err := message.AttachFromEmbedFS("testdata/invalid.txt", nil, WithFileName("attachment.txt"))
|
||||
if err == nil {
|
||||
t.Fatal("expected error, got nil")
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue