Skip to content

Commit 06a69c3

Browse files
committed
Update test cases to account for XDG_BIN_HOME directory addition
1 parent b04f107 commit 06a69c3

4 files changed

+91
-24
lines changed

paths_darwin_test.go

+25-8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func TestDefaultBaseDirs(t *testing.T) {
5656
expected: homeAppSupport,
5757
actual: &xdg.RuntimeDir,
5858
},
59+
&envSample{
60+
name: "XDG_BIN_HOME",
61+
expected: filepath.Join(home, ".local", "bin"),
62+
actual: &xdg.BinHome,
63+
},
5964
&envSample{
6065
name: "XDG_APPLICATION_DIRS",
6166
expected: []string{
@@ -87,10 +92,13 @@ func TestCustomBaseDirs(t *testing.T) {
8792
actual: &xdg.DataHome,
8893
},
8994
&envSample{
90-
name: "XDG_DATA_DIRS",
91-
value: "~/Library/data:/Library/Application Support",
92-
expected: []string{filepath.Join(home, "Library/data"), "/Library/Application Support"},
93-
actual: &xdg.DataDirs,
95+
name: "XDG_DATA_DIRS",
96+
value: "~/Library/data:/Library/Application Support",
97+
expected: []string{
98+
filepath.Join(home, "Library/data"),
99+
"/Library/Application Support",
100+
},
101+
actual: &xdg.DataDirs,
94102
},
95103
&envSample{
96104
name: "XDG_CONFIG_HOME",
@@ -99,10 +107,13 @@ func TestCustomBaseDirs(t *testing.T) {
99107
actual: &xdg.ConfigHome,
100108
},
101109
&envSample{
102-
name: "XDG_CONFIG_DIRS",
103-
value: "~/Library/config:/Library/Preferences",
104-
expected: []string{filepath.Join(home, "Library/config"), "/Library/Preferences"},
105-
actual: &xdg.ConfigDirs,
110+
name: "XDG_CONFIG_DIRS",
111+
value: "~/Library/config:/Library/Preferences",
112+
expected: []string{
113+
filepath.Join(home, "Library/config"),
114+
"/Library/Preferences",
115+
},
116+
actual: &xdg.ConfigDirs,
106117
},
107118
&envSample{
108119
name: "XDG_STATE_HOME",
@@ -122,6 +133,12 @@ func TestCustomBaseDirs(t *testing.T) {
122133
expected: filepath.Join(home, "Library/runtime"),
123134
actual: &xdg.RuntimeDir,
124135
},
136+
&envSample{
137+
name: "XDG_BIN_HOME",
138+
value: "~/Library/bin",
139+
expected: filepath.Join(home, "Library/bin"),
140+
actual: &xdg.BinHome,
141+
},
125142
)
126143
}
127144

paths_plan9_test.go

+11
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func TestDefaultBaseDirs(t *testing.T) {
5050
expected: "/tmp",
5151
actual: &xdg.RuntimeDir,
5252
},
53+
&envSample{
54+
name: "XDG_BIN_HOME",
55+
expected: filepath.Join(home, "bin"),
56+
actual: &xdg.BinHome,
57+
},
5358
&envSample{
5459
name: "XDG_APPLICATION_DIRS",
5560
expected: []string{
@@ -115,6 +120,12 @@ func TestCustomBaseDirs(t *testing.T) {
115120
expected: filepath.Join(homeLib, "runtime"),
116121
actual: &xdg.RuntimeDir,
117122
},
123+
&envSample{
124+
name: "XDG_BIN_HOME",
125+
value: filepath.Join(homeLib, "bin"),
126+
expected: filepath.Join(homeLib, "bin"),
127+
actual: &xdg.BinHome,
128+
},
118129
)
119130
}
120131

paths_unix_test.go

+25-8
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func TestDefaultBaseDirs(t *testing.T) {
5252
expected: filepath.Join("/run/user", strconv.Itoa(os.Getuid())),
5353
actual: &xdg.RuntimeDir,
5454
},
55+
&envSample{
56+
name: "XDG_BIN_HOME",
57+
expected: filepath.Join(home, ".local", "bin"),
58+
actual: &xdg.BinHome,
59+
},
5560
&envSample{
5661
name: "XDG_APPLICATION_DIRS",
5762
expected: []string{
@@ -85,10 +90,13 @@ func TestCustomBaseDirs(t *testing.T) {
8590
actual: &xdg.DataHome,
8691
},
8792
&envSample{
88-
name: "XDG_DATA_DIRS",
89-
value: "~/.local/data:/usr/share",
90-
expected: []string{filepath.Join(home, ".local/data"), "/usr/share"},
91-
actual: &xdg.DataDirs,
93+
name: "XDG_DATA_DIRS",
94+
value: "~/.local/data:/usr/share",
95+
expected: []string{
96+
filepath.Join(home, ".local/data"),
97+
"/usr/share",
98+
},
99+
actual: &xdg.DataDirs,
92100
},
93101
&envSample{
94102
name: "XDG_CONFIG_HOME",
@@ -97,10 +105,13 @@ func TestCustomBaseDirs(t *testing.T) {
97105
actual: &xdg.ConfigHome,
98106
},
99107
&envSample{
100-
name: "XDG_CONFIG_DIRS",
101-
value: "~/.local/config:/etc/xdg",
102-
expected: []string{filepath.Join(home, ".local/config"), "/etc/xdg"},
103-
actual: &xdg.ConfigDirs,
108+
name: "XDG_CONFIG_DIRS",
109+
value: "~/.local/config:/etc/xdg",
110+
expected: []string{
111+
filepath.Join(home, ".local/config"),
112+
"/etc/xdg",
113+
},
114+
actual: &xdg.ConfigDirs,
104115
},
105116
&envSample{
106117
name: "XDG_STATE_HOME",
@@ -120,6 +131,12 @@ func TestCustomBaseDirs(t *testing.T) {
120131
expected: filepath.Join(home, ".local/runtime"),
121132
actual: &xdg.RuntimeDir,
122133
},
134+
&envSample{
135+
name: "XDG_BIN_HOME",
136+
value: "~/bin",
137+
expected: filepath.Join(home, "bin"),
138+
actual: &xdg.BinHome,
139+
},
123140
)
124141
}
125142

paths_windows_test.go

+30-8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func TestDefaultBaseDirs(t *testing.T) {
1919
localAppData := filepath.Join(home, "AppData", "Local")
2020
systemRoot := filepath.Join(systemDrive, "Windows")
2121
programData := filepath.Join(systemDrive, "ProgramData")
22+
programFiles := filepath.Join(systemDrive, "Program Files")
2223

2324
envSamples := []*envSample{
2425
{
@@ -56,11 +57,20 @@ func TestDefaultBaseDirs(t *testing.T) {
5657
expected: localAppData,
5758
actual: &xdg.RuntimeDir,
5859
},
60+
{
61+
name: "XDG_BIN_HOME",
62+
expected: filepath.Join(localAppData, "Programs"),
63+
actual: &xdg.BinHome,
64+
},
5965
{
6066
name: "XDG_APPLICATION_DIRS",
6167
expected: []string{
6268
filepath.Join(roamingAppData, "Microsoft", "Windows", "Start Menu", "Programs"),
6369
filepath.Join(programData, "Microsoft", "Windows", "Start Menu", "Programs"),
70+
programFiles,
71+
filepath.Join(programFiles, "Common Files"),
72+
filepath.Join(localAppData, "Programs"),
73+
filepath.Join(localAppData, "Programs", "Common"),
6474
},
6575
actual: &xdg.ApplicationDirs,
6676
},
@@ -105,10 +115,13 @@ func TestCustomBaseDirs(t *testing.T) {
105115
actual: &xdg.DataHome,
106116
},
107117
&envSample{
108-
name: "XDG_DATA_DIRS",
109-
value: fmt.Sprintf("%s;%s", filepath.Join(localAppData, "Data"), filepath.Join(roamingAppData, "Data")),
110-
expected: []string{filepath.Join(localAppData, "Data"), filepath.Join(roamingAppData, "Data")},
111-
actual: &xdg.DataDirs,
118+
name: "XDG_DATA_DIRS",
119+
value: fmt.Sprintf("%s;%s", filepath.Join(localAppData, "Data"), filepath.Join(roamingAppData, "Data")),
120+
expected: []string{
121+
filepath.Join(localAppData, "Data"),
122+
filepath.Join(roamingAppData, "Data"),
123+
},
124+
actual: &xdg.DataDirs,
112125
},
113126
&envSample{
114127
name: "XDG_CONFIG_HOME",
@@ -117,10 +130,13 @@ func TestCustomBaseDirs(t *testing.T) {
117130
actual: &xdg.ConfigHome,
118131
},
119132
&envSample{
120-
name: "XDG_CONFIG_DIRS",
121-
value: fmt.Sprintf("%s;%s", filepath.Join(localAppData, "Config"), filepath.Join(roamingAppData, "Config")),
122-
expected: []string{filepath.Join(localAppData, "Config"), filepath.Join(roamingAppData, "Config")},
123-
actual: &xdg.ConfigDirs,
133+
name: "XDG_CONFIG_DIRS",
134+
value: fmt.Sprintf("%s;%s", filepath.Join(localAppData, "Config"), filepath.Join(roamingAppData, "Config")),
135+
expected: []string{
136+
filepath.Join(localAppData, "Config"),
137+
filepath.Join(roamingAppData, "Config"),
138+
},
139+
actual: &xdg.ConfigDirs,
124140
},
125141
&envSample{
126142
name: "XDG_STATE_HOME",
@@ -140,6 +156,12 @@ func TestCustomBaseDirs(t *testing.T) {
140156
expected: filepath.Join(programData, "Runtime"),
141157
actual: &xdg.RuntimeDir,
142158
},
159+
&envSample{
160+
name: "XDG_BIN_HOME",
161+
value: filepath.Join(programData, "Programs"),
162+
expected: filepath.Join(programData, "Programs"),
163+
actual: &xdg.BinHome,
164+
},
143165
)
144166

145167
require.NoError(t, os.Setenv("APPDATA", envRoamingAppData))

0 commit comments

Comments
 (0)