@@ -230,8 +230,9 @@ func TestTemplatePull_LatestStdout(t *testing.T) {
230
230
231
231
// ToDir tests that 'templates pull' pulls down the active template
232
232
// and writes it to the correct directory.
233
- // nolint: paralleltest
234
233
func TestTemplatePull_ToDir (t * testing.T ) {
234
+ t .Parallel ()
235
+
235
236
// Prevents the tests from running in parallel.
236
237
tmp := t .TempDir ()
237
238
expectedDest := filepath .Join (tmp , "expected" )
@@ -245,9 +246,13 @@ func TestTemplatePull_ToDir(t *testing.T) {
245
246
givenPath : filepath .Join (tmp , "actual" ),
246
247
},
247
248
{
248
- name : "relative path is cleaned up " ,
249
+ name : "relative path to specific dir is sanitized " ,
249
250
givenPath : "./pulltmp" ,
250
251
},
252
+ {
253
+ name : "relative path to current dir is sanitized" ,
254
+ givenPath : "." ,
255
+ },
251
256
{
252
257
name : "directory traversal is acceptable" ,
253
258
givenPath : "../../../mytmpl" ,
@@ -261,7 +266,12 @@ func TestTemplatePull_ToDir(t *testing.T) {
261
266
for _ , tc := range tests {
262
267
tc := tc
263
268
269
+ // nolint: paralleltest // These tests all share expectedDest
264
270
t .Run (tc .name , func (t * testing.T ) {
271
+ // Use a different working directory to not interfere with actual directory when using relative paths.
272
+ newWD := t .TempDir ()
273
+ require .NoError (t , os .Chdir (newWD ))
274
+
265
275
t .Cleanup (func () {
266
276
_ = os .RemoveAll (tc .givenPath )
267
277
_ = os .RemoveAll (expectedDest )
0 commit comments