Add null check to prevent empty file handle error in msg_test.go

Implemented a null check to ensure the 'fi' file handle is not empty. With the absence of this check, the test was continuing even when 'fi' was empty, leading to null pointer exceptions further down in the code.
This commit is contained in:
Winni Neessen 2023-11-29 17:47:30 +01:00
parent ddcad3710d
commit 5dcbe712ae
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -2589,6 +2589,10 @@ func TestMsg_WriteToFile(t *testing.T) {
if err != nil {
t.Errorf("failed to stat output file: %s", err)
}
if fi == nil {
t.Errorf("received empty file handle")
return
}
if fi.Size() <= 0 {
t.Errorf("output file is expected to contain data but its size is zero")
}