aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-29 09:07:16 +0200
committerRobin Jarry <robin@jarry.cc>2023-09-19 23:01:36 +0200
commit37d5fc691aff24e5e41d5775bb6777b7cb4818c5 (patch)
tree40609ce5b1ff09aab29689dce6ce93d5eccfe041
parentffef6e54dacdf0920f209f3fcc40b72d5027cd30 (diff)
downloadaerc-37d5fc691aff24e5e41d5775bb6777b7cb4818c5.tar.gz
xdg: fix unit tests on macos
When any XDG_*_HOME or XDG_RUNTIME_DIR variables are set, this causes test failures. FAIL: TestConfigPath//home/user/Library/Preferences/aerc/accounts.conf (0.00s) xdg_test.go:86: got "/Users/vitaly/.config/aerc/accounts.conf" expected "/home/user/Library/Preferences/aerc/accounts.conf" Avoid leaking the local user's environment in the unit tests. Always override the XDG_* variables. Fixes: fff16640ad7c ("xdg: add functions to deal with user home paths") Reported-by: Vitaly Ovchinnikov <v@postbox.nz> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Vitaly Ovchinnikov <v@postbox.nz>
-rw-r--r--lib/xdg/xdg_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/xdg/xdg_test.go b/lib/xdg/xdg_test.go
index 6b8eac35..8ab68e06 100644
--- a/lib/xdg/xdg_test.go
+++ b/lib/xdg/xdg_test.go
@@ -14,6 +14,7 @@ func TestCachePath(t *testing.T) {
}{
{
args: []string{"aerc", "foo", "history"},
+ env: map[string]string{"XDG_CACHE_HOME": ""},
expected: map[string]string{
"": "/home/user/.cache/aerc/foo/history",
"darwin": "/home/user/Library/Caches/aerc/foo/history",
@@ -56,6 +57,7 @@ func TestConfigPath(t *testing.T) {
}{
{
args: []string{"aerc", "accounts.conf"},
+ env: map[string]string{"XDG_CONFIG_HOME": ""},
expected: map[string]string{
"": "/home/user/.config/aerc/accounts.conf",
"darwin": "/home/user/Library/Preferences/aerc/accounts.conf",
@@ -98,6 +100,7 @@ func TestDataPath(t *testing.T) {
}{
{
args: []string{"aerc", "templates"},
+ env: map[string]string{"XDG_DATA_HOME": ""},
expected: map[string]string{
"": "/home/user/.local/share/aerc/templates",
"darwin": "/home/user/Library/Application Support/aerc/templates",
@@ -145,6 +148,7 @@ func TestRuntimePath(t *testing.T) {
}{
{
args: []string{"aerc.sock"},
+ env: map[string]string{"XDG_RUNTIME_DIR": ""},
expected: map[string]string{
"": "/run/user/1000/aerc.sock",
"darwin": "/home/user/Library/Application Support/aerc.sock",