mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-28 22:28:25 +00:00
feat: Support project-level Terraform distribution selection (#5167)
Signed-off-by: Andrew Borg <andrew.b.borg@gmail.com> Co-authored-by: PePe Amengual <2208324+jamengual@users.noreply.github.com> Co-authored-by: Simon Heather <32168619+X-Guardian@users.noreply.github.com>
This commit is contained in:
@@ -73,6 +73,7 @@ var testFlags = map[string]interface{}{
|
||||
CheckoutStrategyFlag: CheckoutStrategyMerge,
|
||||
CheckoutDepthFlag: 0,
|
||||
DataDirFlag: "/path",
|
||||
DefaultTFDistributionFlag: "terraform",
|
||||
DefaultTFVersionFlag: "v0.11.0",
|
||||
DisableApplyAllFlag: true,
|
||||
DisableMarkdownFoldingFlag: true,
|
||||
@@ -977,6 +978,46 @@ func TestExecute_AutoplanFileList(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecute_ValidateDefaultTFDistribution(t *testing.T) {
|
||||
cases := []struct {
|
||||
description string
|
||||
flags map[string]interface{}
|
||||
expectErr string
|
||||
}{
|
||||
{
|
||||
"terraform",
|
||||
map[string]interface{}{
|
||||
DefaultTFDistributionFlag: "terraform",
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"opentofu",
|
||||
map[string]interface{}{
|
||||
DefaultTFDistributionFlag: "opentofu",
|
||||
},
|
||||
"",
|
||||
},
|
||||
{
|
||||
"errs on invalid distribution",
|
||||
map[string]interface{}{
|
||||
DefaultTFDistributionFlag: "invalid_distribution",
|
||||
},
|
||||
"invalid tf distribution: expected one of terraform or opentofu",
|
||||
},
|
||||
}
|
||||
for _, testCase := range cases {
|
||||
t.Log("Should validate default tf distribution when " + testCase.description)
|
||||
c := setupWithDefaults(testCase.flags, t)
|
||||
err := c.Execute()
|
||||
if testCase.expectErr != "" {
|
||||
ErrEquals(t, testCase.expectErr, err)
|
||||
} else {
|
||||
Ok(t, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setup(flags map[string]interface{}, t *testing.T) *cobra.Command {
|
||||
vipr := viper.New()
|
||||
for k, v := range flags {
|
||||
|
||||
Reference in New Issue
Block a user