mirror of
https://github.com/Jguer/yay.git
synced 2024-11-07 17:47:21 +01:00
888fb4b1d0
* add missing locales * use t.Setenv instead of os.Setenv for tests * locale: present y/n if localisation is not latin. Always accept y/n in every case * question: use operation info for question * edge case where localised n is equal to default y * add tests for basic locales
29 lines
675 B
Go
29 lines
675 B
Go
package settings
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// 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 := t.TempDir()
|
|
require.NoError(t, os.Unsetenv("XDG_CACHE_HOME"))
|
|
require.NoError(t, os.Unsetenv("HOME"))
|
|
t.Setenv("SUDO_USER", "test")
|
|
t.Setenv("TMPDIR", dir)
|
|
|
|
got, err := getCacheHome()
|
|
require.NoError(t, err)
|
|
assert.Equal(t, filepath.Join(dir, "yay"), got)
|
|
|
|
require.NoError(t, os.Unsetenv("TMPDIR"))
|
|
require.NoError(t, os.Unsetenv("SUDO_USER"))
|
|
}
|