Skip to content

Commit

Permalink
added tests for rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelightning committed Aug 31, 2023
1 parent 24e7b9b commit e72ce96
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions logging/logfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ func TestLogFile_openNew(t *testing.T) {
require.Contains(t, string(content), msg)
}

func TestLogFile_renameCurrentFile(t *testing.T) {
logFile := LogFile{
fileName: "consul.log",
logPath: testutil.TempDir(t, ""),
duration: defaultRotateDuration,
}
err := logFile.openNew()
require.NoError(t, err)

err = logFile.renameCurrentFile()
require.NoError(t, err)

_, err = os.ReadFile(logFile.FileInfo.Name())
require.Contains(t, err.Error(), "no such file or directory")
}

func TestLogFile_Rotation_MaxBytes(t *testing.T) {
tempDir := testutil.TempDir(t, "LogWriterBytes")
logFile := LogFile{
Expand Down

0 comments on commit e72ce96

Please sign in to comment.