Skip to content

Commit

Permalink
Add tests for Msg GetBoundary method
Browse files Browse the repository at this point in the history
Introduce unit tests for the GetBoundary method in the Msg type. Ensure proper functionality for messages with and without a boundary set.
  • Loading branch information
wneessen committed Oct 27, 2024
1 parent b7ca41a commit f261973
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f261973

Please sign in to comment.