Add nil check in testMessage helper function

Added a conditional check to ensure 'NewMsg()' does not return nil in the 'testMessage' helper function. This update will prevent potential nil pointer dereferences and improve the robustness of the test.
This commit is contained in:
Winni Neessen 2024-10-26 21:07:04 +02:00
parent 42c63791ef
commit cf117d320b
Signed by: wneessen
GPG key ID: 385AC9889632126E

View file

@ -3527,6 +3527,9 @@ func parseJSONLog(t *testing.T, buf *bytes.Buffer) logData {
func testMessage(t *testing.T) *Msg {
t.Helper()
message := NewMsg()
if message == nil {
t.Fatal("failed to create new message")
}
if err := message.From(TestSenderValid); err != nil {
t.Errorf("failed to set sender address: %s", err)
}