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.
This commit is contained in:
Winni Neessen 2024-10-27 10:13:14 +01:00
parent b7ca41af81
commit f2619737e8
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -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. // 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. // 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, func checkAddrHeader(t *testing.T, message *Msg, header AddrHeader, fn string, field, wantFields int,