@@ -176,3 +176,70 @@ func TestMacOS_ProfileNetworkSection(t *testing.T) {
176176 })
177177 }
178178}
179+
180+ // TestExpandMacOSTmpPaths verifies that /tmp and /private/tmp paths are properly mirrored.
181+ func TestExpandMacOSTmpPaths (t * testing.T ) {
182+ tests := []struct {
183+ name string
184+ input []string
185+ want []string
186+ }{
187+ {
188+ name : "mirrors /tmp to /private/tmp" ,
189+ input : []string {"." , "/tmp" },
190+ want : []string {"." , "/tmp" , "/private/tmp" },
191+ },
192+ {
193+ name : "mirrors /private/tmp to /tmp" ,
194+ input : []string {"." , "/private/tmp" },
195+ want : []string {"." , "/private/tmp" , "/tmp" },
196+ },
197+ {
198+ name : "no change when both present" ,
199+ input : []string {"." , "/tmp" , "/private/tmp" },
200+ want : []string {"." , "/tmp" , "/private/tmp" },
201+ },
202+ {
203+ name : "no change when neither present" ,
204+ input : []string {"." , "~/.cache" },
205+ want : []string {"." , "~/.cache" },
206+ },
207+ {
208+ name : "mirrors /tmp/fence to /private/tmp/fence" ,
209+ input : []string {"." , "/tmp/fence" },
210+ want : []string {"." , "/tmp/fence" , "/private/tmp/fence" },
211+ },
212+ {
213+ name : "mirrors /private/tmp/fence to /tmp/fence" ,
214+ input : []string {"." , "/private/tmp/fence" },
215+ want : []string {"." , "/private/tmp/fence" , "/tmp/fence" },
216+ },
217+ {
218+ name : "mirrors nested subdirectory" ,
219+ input : []string {"." , "/tmp/foo/bar" },
220+ want : []string {"." , "/tmp/foo/bar" , "/private/tmp/foo/bar" },
221+ },
222+ {
223+ name : "no duplicate when mirror already present" ,
224+ input : []string {"." , "/tmp/fence" , "/private/tmp/fence" },
225+ want : []string {"." , "/tmp/fence" , "/private/tmp/fence" },
226+ },
227+ }
228+
229+ for _ , tt := range tests {
230+ t .Run (tt .name , func (t * testing.T ) {
231+ got := expandMacOSTmpPaths (tt .input )
232+
233+ if len (got ) != len (tt .want ) {
234+ t .Errorf ("expandMacOSTmpPaths() = %v, want %v" , got , tt .want )
235+ return
236+ }
237+
238+ for i , v := range got {
239+ if v != tt .want [i ] {
240+ t .Errorf ("expandMacOSTmpPaths()[%d] = %v, want %v" , i , v , tt .want [i ])
241+ }
242+ }
243+ })
244+ }
245+ }
0 commit comments