Test for message part deletion

Added a test for the `Part.Delete` method
This commit is contained in:
Winni Neessen 2023-01-28 14:42:29 +01:00
parent 9724a2b523
commit c602ba103f
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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()