forked from totmicro/atlantis-yaml-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactors and adding some tests
- Loading branch information
1 parent
1ad114e
commit 6d1949d
Showing
11 changed files
with
952 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package cmd | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/totmicro/atlantis-yaml-generator/pkg/atlantis" | ||
) | ||
|
||
func TestDefineWhenModifiedList(t *testing.T) { | ||
defaultList := atlantis.DefaultWhenModified | ||
customList := []string{"x", "y", "z"} | ||
|
||
assert.Equal(t, defaultList, defineWhenModifiedList("")) | ||
assert.Equal(t, customList, defineWhenModifiedList("x,y,z")) | ||
} | ||
|
||
func TestDefineProjectPatternDetector(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
patternDetector string | ||
workflow string | ||
expectedResult string | ||
}{ | ||
{ | ||
name: "Default for single-workspace", | ||
patternDetector: "", | ||
workflow: "single-workspace", | ||
expectedResult: "main.tf", | ||
}, | ||
{ | ||
name: "Default for multi-workspace", | ||
patternDetector: "", | ||
workflow: "multi-workspace", | ||
expectedResult: "workspace_vars", | ||
}, | ||
{ | ||
name: "Custom for multi-workspace", | ||
patternDetector: "mypattern", | ||
workflow: "multi-workspace", | ||
expectedResult: "mypattern", | ||
}, | ||
{ | ||
name: "Custom for single-workspace", | ||
patternDetector: "mypattern", | ||
workflow: "single-workspace", | ||
expectedResult: "mypattern", | ||
}, | ||
{ | ||
name: "Undefined workflow", | ||
patternDetector: "", | ||
workflow: "undefined-workspace", | ||
expectedResult: "Workflow undefined-workspace not found", | ||
}, | ||
{ | ||
name: "Undefined workflow with custom pattern", | ||
patternDetector: "mypattern", | ||
workflow: "undefined-workspace", | ||
expectedResult: "Workflow undefined-workspace not found", | ||
}, | ||
} | ||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
result := defineProjectPatternDetector(tc.patternDetector, tc.workflow) | ||
assert.Equal(t, tc.expectedResult, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.