1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 00:07:25 +00:00
restic/internal/backend/cache/dir_test.go
2024-05-24 23:04:06 +02:00

31 lines
561 B
Go

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 func() {
err := os.Unsetenv("RESTIC_CACHE_DIR")
if err != nil {
t.Fatal(err)
}
}()
}
dir, err := DefaultDir()
rtest.Equals(t, cachedir, dir)
rtest.OK(t, err)
}