From f2619737e876752269c13a3d68d10b89d017349b Mon Sep 17 00:00:00 2001 From: Winni Neessen Date: Sun, 27 Oct 2024 10:13:14 +0100 Subject: [PATCH] Add tests for Msg GetBoundary method Introduce unit tests for the GetBoundary method in the Msg type. Ensure proper functionality for messages with and without a boundary set. --- msg_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/msg_test.go b/msg_test.go index b09949d..1d3089c 100644 --- a/msg_test.go +++ b/msg_test.go @@ -3288,6 +3288,27 @@ func TestMsg_GetAttachments(t *testing.T) { }) } +func TestMsg_GetBoundary(t *testing.T) { + t.Run("GetBoundary", func(t *testing.T) { + message := NewMsg(WithBoundary("test")) + if message == nil { + t.Fatal("message is nil") + } + if message.GetBoundary() != "test" { + t.Errorf("GetBoundary: expected %s, got: %s", "test", message.GetBoundary()) + } + }) + t.Run("GetBoundary with no boundary", func(t *testing.T) { + message := NewMsg() + if message == nil { + t.Fatal("message is nil") + } + if message.GetBoundary() != "" { + t.Errorf("GetBoundary: expected empty, got: %s", message.GetBoundary()) + } + }) +} + // checkAddrHeader verifies the correctness of an AddrHeader in a Msg based on the provided criteria. // It checks whether the AddrHeader contains the correct address, name, and number of fields. func checkAddrHeader(t *testing.T, message *Msg, header AddrHeader, fn string, field, wantFields int,