mirror of
https://github.com/wneessen/go-mail.git
synced 2024-11-22 13:50:49 +01:00
Test for message part deletion
Added a test for the `Part.Delete` method
This commit is contained in:
parent
9724a2b523
commit
c602ba103f
1 changed files with 16 additions and 0 deletions
16
part_test.go
16
part_test.go
|
@ -241,6 +241,22 @@ func TestPart_SetContent(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestPart_Delete tests Part.Delete
|
||||||
|
func TestPart_Delete(t *testing.T) {
|
||||||
|
c := "This is a test with ümläutß"
|
||||||
|
m := NewMsg()
|
||||||
|
m.SetBodyString(TypeTextPlain, c)
|
||||||
|
pl, err := getPartList(m)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pl[0].Delete()
|
||||||
|
if !pl[0].del {
|
||||||
|
t.Errorf("Delete failed. Expected: %t, got: %t", true, pl[0].del)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// getPartList is a helper function
|
// getPartList is a helper function
|
||||||
func getPartList(m *Msg) ([]*Part, error) {
|
func getPartList(m *Msg) ([]*Part, error) {
|
||||||
pl := m.GetParts()
|
pl := m.GetParts()
|
||||||
|
|
Loading…
Reference in a new issue