Skip to content

Commit 8fdda5a

Browse files
test(tracking): isolate config tests from user home
1 parent b8749e5 commit 8fdda5a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

internal/tracking/config_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package tracking
22

3-
import "testing"
3+
import (
4+
"path/filepath"
5+
"testing"
6+
)
47

58
func TestConfigRoundTrip(t *testing.T) {
69
// Use temp dir
710
tmpDir := t.TempDir()
8-
t.Setenv("XDG_CONFIG_HOME", tmpDir)
11+
t.Setenv("HOME", tmpDir)
12+
t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpDir, "xdg-config"))
913

1014
cfg := &Config{
1115
Enabled: true,
@@ -36,7 +40,8 @@ func TestConfigRoundTrip(t *testing.T) {
3640

3741
func TestLoadConfigMissing(t *testing.T) {
3842
tmpDir := t.TempDir()
39-
t.Setenv("XDG_CONFIG_HOME", tmpDir)
43+
t.Setenv("HOME", tmpDir)
44+
t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpDir, "xdg-config"))
4045

4146
cfg, err := LoadConfig()
4247
if err != nil {

0 commit comments

Comments
 (0)