Improve test
This commit is contained in:
parent
2fdca5d310
commit
47ddd34266
1 changed files with 6 additions and 7 deletions
|
@ -2,9 +2,10 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsExcludedByFile(t *testing.T) {
|
func TestIsExcludedByFile(t *testing.T) {
|
||||||
|
@ -29,13 +30,11 @@ func TestIsExcludedByFile(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, tc := range tests {
|
for _, tc := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
tempDir, err := ioutil.TempDir("", "restic-test-")
|
tempDir, cleanup := test.TempDir(t)
|
||||||
if err != nil {
|
defer cleanup()
|
||||||
t.Fatalf("could not create temp dir: %v", err)
|
|
||||||
}
|
|
||||||
defer os.RemoveAll(tempDir)
|
|
||||||
foo := filepath.Join(tempDir, "foo")
|
foo := filepath.Join(tempDir, "foo")
|
||||||
err = ioutil.WriteFile(foo, []byte("foo"), 0666)
|
err := ioutil.WriteFile(foo, []byte("foo"), 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("could not write file: %v", err)
|
t.Fatalf("could not write file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue