1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2024-12-14 11:57:52 +00:00

use a shorter tempdir on macOS

By default macOS does something like this:

/var/folders/08/j4g_jn953lngpvgmyg8dygk00000gn/T/

breaking unix socket paths of gnupg.
This commit is contained in:
Jörg Thalheim 2020-07-22 15:41:43 +01:00
parent 1279274ddc
commit 5e95616f0f
No known key found for this signature in database
GPG key ID: 003F2096411B5F92

View file

@ -20,10 +20,19 @@ func ok(tb testing.TB, err error) {
}
}
func TempRoot() string {
if runtime.GOOS == "darwin" {
// macOS make its TEMPDIR long enough for unix socket to break
return "/tmp"
} else {
return os.TempDir()
}
}
func TestCli(t *testing.T) {
_, filename, _, _ := runtime.Caller(0)
assets := path.Join(path.Dir(filename), "test-assets")
tempdir, err := ioutil.TempDir("/tmp", "testdir")
tempdir, err := ioutil.TempDir(TempRoot(), "testdir")
ok(t, err)
defer os.RemoveAll(tempdir)