summaryrefslogtreecommitdiffstats
path: root/modules/log/file_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/log/file_test.go')
-rw-r--r--modules/log/file_test.go20
1 files changed, 5 insertions, 15 deletions
diff --git a/modules/log/file_test.go b/modules/log/file_test.go
index c3074b69df..cc2b9fe077 100644
--- a/modules/log/file_test.go
+++ b/modules/log/file_test.go
@@ -14,15 +14,11 @@ import (
"testing"
"time"
- "code.gitea.io/gitea/modules/util"
-
"github.com/stretchr/testify/assert"
)
func TestFileLoggerFails(t *testing.T) {
- tmpDir, err := os.MkdirTemp("", "TestFileLogger")
- assert.NoError(t, err)
- defer util.RemoveAll(tmpDir)
+ tmpDir := t.TempDir()
prefix := "TestPrefix "
level := INFO
@@ -34,7 +30,7 @@ func TestFileLoggerFails(t *testing.T) {
// assert.True(t, ok)
// Fail if there is bad json
- err = fileLogger.Init("{")
+ err := fileLogger.Init("{")
assert.Error(t, err)
// Fail if there is no filename
@@ -47,9 +43,7 @@ func TestFileLoggerFails(t *testing.T) {
}
func TestFileLogger(t *testing.T) {
- tmpDir, err := os.MkdirTemp("", "TestFileLogger")
- assert.NoError(t, err)
- defer util.RemoveAll(tmpDir)
+ tmpDir := t.TempDir()
prefix := "TestPrefix "
level := INFO
@@ -150,9 +144,7 @@ func TestFileLogger(t *testing.T) {
}
func TestCompressFileLogger(t *testing.T) {
- tmpDir, err := os.MkdirTemp("", "TestFileLogger")
- assert.NoError(t, err)
- defer util.RemoveAll(tmpDir)
+ tmpDir := t.TempDir()
prefix := "TestPrefix "
level := INFO
@@ -210,9 +202,7 @@ func TestCompressFileLogger(t *testing.T) {
}
func TestCompressOldFile(t *testing.T) {
- tmpDir, err := os.MkdirTemp("", "TestFileLogger")
- assert.NoError(t, err)
- defer util.RemoveAll(tmpDir)
+ tmpDir := t.TempDir()
fname := filepath.Join(tmpDir, "test")
nonGzip := filepath.Join(tmpDir, "test-nonGzip")