mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
24 lines
568 B
Go
24 lines
568 B
Go
package settings
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// GIVEN no user directories and sudo user
|
|
// WHEN cache home is selected
|
|
// THEN the selected cache home should be in the tmp dir
|
|
func Test_getCacheHome(t *testing.T) {
|
|
dir, err := os.MkdirTemp(os.TempDir(), "yay-cache-home")
|
|
assert.NoError(t, err)
|
|
os.Unsetenv("XDG_CACHE_HOME")
|
|
os.Unsetenv("HOME")
|
|
os.Setenv("SUDO_USER", "test")
|
|
os.Setenv("TMPDIR", dir)
|
|
got, err := getCacheHome()
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, filepath.Join(dir, "yay"), got)
|
|
}
|