test: make tests stable (#1968)

* test: make tests stable

* test: fix fails
This commit is contained in:
Kevin Wan
2022-06-04 23:46:29 +08:00
committed by GitHub
parent f366e1d936
commit af05219b70
5 changed files with 15 additions and 14 deletions

View File

@@ -57,6 +57,12 @@ func TestRotateLoggerGetBackupFilename(t *testing.T) {
}
func TestRotateLoggerMayCompressFile(t *testing.T) {
old := os.Stdout
os.Stdout = os.NewFile(0, os.DevNull)
defer func() {
os.Stdout = old
}()
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
if len(filename) > 0 {
@@ -70,6 +76,12 @@ func TestRotateLoggerMayCompressFile(t *testing.T) {
}
func TestRotateLoggerMayCompressFileTrue(t *testing.T) {
old := os.Stdout
os.Stdout = os.NewFile(0, os.DevNull)
defer func() {
os.Stdout = old
}()
filename, err := fs.TempFilenameWithText("foo")
assert.Nil(t, err)
logger, err := NewLogger(filename, new(DailyRotateRule), true)