Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcportabellaclotet-mt committed Oct 13, 2023
1 parent f5e53ba commit a7dae73
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Run the tool using the following command:

Currenlty `atlantis-yaml-generator` support 2 workflow types:
- `single-workspace`: Intended for Terraform configurations that do not utilize multiple workspaces. In this context, the pattern detector parameters establish the criteria for identifying project folders. For instance, if the pattern-detector is set to main.tf (file), and this file is located at database/dev/main.tf, the resulting project would be labeled as database-env. Consequently, Terraform commands would be executed within the database/dev folder.
- `multiple-workspace`: Intended for Terraform configurations that utilize multiple workspaces. In this context, the pattern detector parameters establish the criteria for identifying project folders. For instance, if the pattern-detector is set to workspace_vars (folder), and there are several files located in this folder, i.e. (database/workspace_vars/dev.tf |database/workspace_vars/staging.tf ), the resulting projects would be labeled as (database-dev|database-staging). Consequently, Terraform commands would be executed within the database/workspace_vars folder.
- `multiple-workspace`: Intended for Terraform configurations that utilize multiple workspaces. In this context, the pattern detector parameters establish the criteria for identifying project folders. For instance, if the pattern-detector is set to workspace_vars (folder), and there are several files located in this folder, i.e. (database/workspace_vars/dev.tf |database/workspace_vars/staging.tf ), the resulting projects would be labeled as (database-dev|database-staging). Consequently, Terraform commands would be executed within the database folder. Please be aware that in this scenario, the Atlantis workflow requires the use of the -var-file parameter, specifically in the form of -var-file=(workspace_vars/dev.tf|workspace_vars/staging.tf).

If there is the need for additional workflows, they can be easily added at code level. Current code is ready to easily add new workflows, while sharing common actions.
```
Expand Down
24 changes: 23 additions & 1 deletion pkg/atlantis/atlantis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ func TestScanProjectFolders(t *testing.T) {
patternDetector: "workspace_vars",
changedFiles: []string{
"multiworkspace/workspace_vars/test1.tfvars",
"multiworkspace2/workspace_vars/test1.tfvars"},
"multiworkspace2/workspace_vars/test1.tfvars",
"multiworkspace2/workspace_vars/test2.tfvars",
},
expectedProjectFolder: []ProjectFolder{
{Path: "multiworkspace"},
{Path: "multiworkspace2"},
Expand Down Expand Up @@ -522,6 +524,26 @@ func TestDetectProjectWorkspaces(t *testing.T) {
},
expectedErr: false,
},
{
name: "multi-workspace",
foldersList: []ProjectFolder{{Path: "mockproject/multiworkspace"}, {Path: "mockproject/multiworkspace2"}},
workflow: "multi-workspace",
patternDetector: "workspace_vars",
changedFiles: []string{"mockproject/multiworkspace/workspace_vars/test1.tfvars",
"mockproject/multiworkspace2/workspace_vars/test2.tfvars",
},
expectedFoldersList: []ProjectFolder{
{
Path: "mockproject/multiworkspace",
WorkspaceList: []string{"test1"},
},
{
Path: "mockproject/multiworkspace2",
WorkspaceList: []string{"test2"},
},
},
expectedErr: false,
},
// Add more test cases as needed
}

Expand Down
Empty file.

0 comments on commit a7dae73

Please sign in to comment.