@@ -365,15 +365,51 @@ func TestProjectConfig_triggeredWorkspaces(t *testing.T) {
365365 },
366366 },
367367 {
368- name : "subdir -and-dir -same-name" ,
369- cfgYaml : tfbuddyYamlSubdirAndDirSameName ,
368+ name : "dir -and-subdir -same-name--dir-change " ,
369+ cfgYaml : tfbuddyYamlDirAndSubdirSameName ,
370370 args : args {
371371 modifiedFiles : []string {
372372 "workspaces/main.tf" ,
373373 },
374374 },
375375 want : []* TFCWorkspace {
376- testLoadConfig (t , tfbuddyYamlSubdirAndDirSameName ).Workspaces [1 ],
376+ testLoadConfig (t , tfbuddyYamlDirAndSubdirSameName ).Workspaces [0 ], // "workspaces" workspace
377+ },
378+ },
379+ {
380+ name : "dir-and-subdir-same-name--subdir-change" ,
381+ cfgYaml : tfbuddyYamlDirAndSubdirSameName ,
382+ args : args {
383+ modifiedFiles : []string {
384+ "aws/workspaces/main.tf" ,
385+ },
386+ },
387+ want : []* TFCWorkspace {
388+ testLoadConfig (t , tfbuddyYamlDirAndSubdirSameName ).Workspaces [1 ], // "aws/workspaces" workspace
389+ },
390+ },
391+ {
392+ name : "subdir-and-dir-same-name--dir-change" ,
393+ cfgYaml : tfbuddyYamlSubdirAndDirSameName ,
394+ args : args {
395+ modifiedFiles : []string {
396+ "test2/test3/main.tf" ,
397+ },
398+ },
399+ want : []* TFCWorkspace {
400+ testLoadConfig (t , tfbuddyYamlSubdirAndDirSameName ).Workspaces [1 ], // "test2/test3" workspace
401+ },
402+ },
403+ {
404+ name : "subdir-and-dir-same-name--subdir-change" ,
405+ cfgYaml : tfbuddyYamlSubdirAndDirSameName ,
406+ args : args {
407+ modifiedFiles : []string {
408+ "test1/test2/test3/main.tf" ,
409+ },
410+ },
411+ want : []* TFCWorkspace {
412+ testLoadConfig (t , tfbuddyYamlSubdirAndDirSameName ).Workspaces [0 ], // "test1/test2/test3" workspace
377413 },
378414 },
379415 {
@@ -718,15 +754,27 @@ workspaces:
718754
719755`
720756
721- const tfbuddyYamlSubdirAndDirSameName = `
757+ const tfbuddyYamlDirAndSubdirSameName = `
722758---
723759workspaces:
760+ - name: workspaces
761+ organization: foo-corp
762+ dir: workspaces
724763 - name: aws-workspaces
725764 organization: foo-corp
726765 dir: aws/workspaces
727- - name: workspaces
766+
767+ `
768+
769+ const tfbuddyYamlSubdirAndDirSameName = `
770+ ---
771+ workspaces:
772+ - name: subdir
728773 organization: foo-corp
729- dir: workspaces
774+ dir: test1/test2/test3
775+ - name: dir
776+ organization: foo-corp
777+ dir: test2/test3
730778
731779`
732780
0 commit comments