test: make tests stable (#1968)
* test: make tests stable * test: fix fails
This commit is contained in:
@@ -328,9 +328,5 @@ func gzipFile(file string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// ignore errors on remove, it most happens on unit tests,
|
||||
// it caused lots of troubles on GitHub actions.
|
||||
// and even on production, remove errors are not important.
|
||||
_ = os.Remove(file)
|
||||
return nil
|
||||
return os.Remove(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)
|
||||
|
||||
Reference in New Issue
Block a user