Honor RESTIC_CACHE_DIR on Mac and Windows
This commit is contained in:
parent
58bd165253
commit
5cd0bce452
3 changed files with 41 additions and 54 deletions
26
internal/cache/dir_test.go
vendored
Normal file
26
internal/cache/dir_test.go
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
package cache
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
)
|
||||
|
||||
// DefaultDir should honor RESTIC_CACHE_DIR on all platforms.
|
||||
func TestCacheDirEnv(t *testing.T) {
|
||||
cachedir := os.Getenv("RESTIC_CACHE_DIR")
|
||||
|
||||
if cachedir == "" {
|
||||
cachedir = "/doesnt/exist"
|
||||
err := os.Setenv("RESTIC_CACHE_DIR", cachedir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Unsetenv("RESTIC_CACHE_DIR")
|
||||
}
|
||||
|
||||
dir, err := DefaultDir()
|
||||
rtest.Equals(t, cachedir, dir)
|
||||
rtest.OK(t, err)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue