From c602ba103f53c2635a4f8fc3fcd874d67c9d3a33 Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sat, 28 Jan 2023 14:42:29 +0100 Subject: [PATCH] Test for message part deletion Added a test for the `Part.Delete` method --- part_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/part_test.go b/part_test.go index 55bc82d..d3ceef2 100644 --- a/part_test.go +++ b/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 func getPartList(m *Msg) ([]*Part, error) { pl := m.GetParts()