feat(GODT-2691): close logrus output file on exit.

This commit is contained in:
Xavier Michelon
2023-06-28 13:34:19 +02:00
parent c267168cb7
commit 7b7c9093ce
5 changed files with 52 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import (
"testing"
"github.com/ProtonMail/proton-bridge/v3/internal/constants"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
@ -93,3 +94,12 @@ func TestLogging_GetOrderedLogFileListForBugReport(t *testing.T) {
filepath.Join(dir, string(sessionID1)+"_lau_000"+fileSuffix),
}, filePaths)
}
func TestLogging_Close(t *testing.T) {
d := t.TempDir()
closer, err := Init(d, NewSessionID(), constants.AppName, 1, DefaultPruningSize, "debug")
require.NoError(t, err)
logrus.Debug("Test") // because we set max log file size to 1, this will force a rotation of the log file.
require.NotNil(t, closer)
require.NoError(t, closer.Close())
}