Skip to content

Commit

Permalink
fix: Add some more tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Plant <sam.plant@zapier.com>
  • Loading branch information
sampsre committed Nov 28, 2024
1 parent 075b62a commit 1fe91d2
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions pkg/tfc_trigger/project_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,28 +364,52 @@ func TestProjectConfig_triggeredWorkspaces(t *testing.T) {
testLoadConfig(t, tfbuddyYamlSharedTriggerDirMultipleWorkspaces).Workspaces[1],
},
},
{
name: "dir-and-subdir-same-name--dir-change",
cfgYaml: tfbuddyYamlDirAndSubdirSameName,
args: args{
modifiedFiles: []string{
"workspaces/main.tf",
},
},
want: []*TFCWorkspace{
testLoadConfig(t, tfbuddyYamlDirAndSubdirSameName).Workspaces[0], // "workspaces" workspace
},
},
{
name: "dir-and-subdir-same-name--subdir-change",
cfgYaml: tfbuddyYamlDirAndSubdirSameName,
args: args{
modifiedFiles: []string{
"aws/workspaces/main.tf",
},
},
want: []*TFCWorkspace{
testLoadConfig(t, tfbuddyYamlDirAndSubdirSameName).Workspaces[1], // "aws/workspaces" workspace
},
},
{
name: "subdir-and-dir-same-name--dir-change",
cfgYaml: tfbuddyYamlSubdirAndDirSameName,
args: args{
modifiedFiles: []string{
"workspaces/main.tf",
"test2/test3/main.tf",
},
},
want: []*TFCWorkspace{
testLoadConfig(t, tfbuddyYamlSubdirAndDirSameName).Workspaces[0], // "workspaces" workspace
testLoadConfig(t, tfbuddyYamlSubdirAndDirSameName).Workspaces[1], // "test2/test3" workspace
},
},
{
name: "subdir-and-dir-same-name--subdir-change",
cfgYaml: tfbuddyYamlSubdirAndDirSameName,
args: args{
modifiedFiles: []string{
"aws/workspaces/main.tf",
"test1/test2/test3/main.tf",
},
},
want: []*TFCWorkspace{
testLoadConfig(t, tfbuddyYamlSubdirAndDirSameName).Workspaces[1], // "aws/workspaces" workspace
testLoadConfig(t, tfbuddyYamlSubdirAndDirSameName).Workspaces[0], // "test1/test2/test3" workspace
},
},
{
Expand Down Expand Up @@ -730,7 +754,7 @@ workspaces:
`

const tfbuddyYamlSubdirAndDirSameName = `
const tfbuddyYamlDirAndSubdirSameName = `
---
workspaces:
- name: workspaces
Expand All @@ -742,6 +766,18 @@ workspaces:
`

const tfbuddyYamlSubdirAndDirSameName = `
---
workspaces:
- name: subdir
organization: foo-corp
dir: test1/test2/test3
- name: dir
organization: foo-corp
dir: test2/test3
`

const tfbuddyYamlDifferentDirSameSubdir = `
---
workspaces:
Expand Down

0 comments on commit 1fe91d2

Please sign in to comment.