mirror of
https://github.com/restic/restic.git
synced 2026-07-16 04:04:53 +00:00
test: Use testing.T.Cleanup to remove tempdirs
This commit is contained in:
@@ -14,8 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func TestCollectTargets(t *testing.T) {
|
||||
dir, cleanup := rtest.TempDir(t)
|
||||
defer cleanup()
|
||||
dir := rtest.TempDir(t)
|
||||
|
||||
fooSpace := "foo "
|
||||
barStar := "bar*" // Must sort before the others, below.
|
||||
|
||||
@@ -84,8 +84,7 @@ func TestIsExcludedByFile(t *testing.T) {
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
tempDir, cleanup := test.TempDir(t)
|
||||
defer cleanup()
|
||||
tempDir := test.TempDir(t)
|
||||
|
||||
foo := filepath.Join(tempDir, "foo")
|
||||
err := os.WriteFile(foo, []byte("foo"), 0666)
|
||||
@@ -115,8 +114,7 @@ func TestIsExcludedByFile(t *testing.T) {
|
||||
// cancel each other out. It was initially written to demonstrate a bug in
|
||||
// rejectIfPresent.
|
||||
func TestMultipleIsExcludedByFile(t *testing.T) {
|
||||
tempDir, cleanup := test.TempDir(t)
|
||||
defer cleanup()
|
||||
tempDir := test.TempDir(t)
|
||||
|
||||
// Create some files in a temporary directory.
|
||||
// Files in UPPERCASE will be used as exclusion triggers later on.
|
||||
@@ -240,8 +238,7 @@ func TestParseInvalidSizeStr(t *testing.T) {
|
||||
// TestIsExcludedByFileSize is for testing the instance of
|
||||
// --exclude-larger-than parameters
|
||||
func TestIsExcludedByFileSize(t *testing.T) {
|
||||
tempDir, cleanup := test.TempDir(t)
|
||||
defer cleanup()
|
||||
tempDir := test.TempDir(t)
|
||||
|
||||
// Max size of file is set to be 1k
|
||||
maxSizeStr := "1k"
|
||||
|
||||
@@ -31,8 +31,7 @@ func Test_PrintFunctionsRespectsGlobalStdout(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadRepo(t *testing.T) {
|
||||
tempDir, cleanup := test.TempDir(t)
|
||||
defer cleanup()
|
||||
tempDir := test.TempDir(t)
|
||||
|
||||
// test --repo option
|
||||
var opts GlobalOptions
|
||||
|
||||
@@ -160,10 +160,8 @@ func TestFillSecondaryGlobalOpts(t *testing.T) {
|
||||
}
|
||||
|
||||
//Create temp dir to create password file.
|
||||
dir, cleanup := rtest.TempDir(t)
|
||||
defer cleanup()
|
||||
|
||||
cleanup = rtest.Chdir(t, dir)
|
||||
dir := rtest.TempDir(t)
|
||||
cleanup := rtest.Chdir(t, dir)
|
||||
defer cleanup()
|
||||
|
||||
//Create temporary password file
|
||||
|
||||
Reference in New Issue
Block a user