mirror of
https://github.com/3bbbeau/tfvars-atlantis-config.git
synced 2024-11-22 14:00:52 +00:00
101 lines
2.0 KiB
Go
101 lines
2.0 KiB
Go
package repocfg
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
"github.com/runatlantis/atlantis/server/core/config/raw"
|
|
)
|
|
|
|
func Test_NewFrom(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
tests := []struct {
|
|
name string
|
|
components []Component
|
|
want *ExtRawRepoCfg
|
|
}{
|
|
{
|
|
name: "WithNestedVars",
|
|
components: []Component{
|
|
{
|
|
Path: "test",
|
|
VarFiles: []string{"test/vars/dev.tfvars", "test/vars/nested/stg.tfvars"},
|
|
},
|
|
},
|
|
want: &ExtRawRepoCfg{
|
|
RepoCfg: raw.RepoCfg{
|
|
Version: ptr(3),
|
|
Automerge: ptr(false),
|
|
ParallelPlan: ptr(false),
|
|
ParallelApply: ptr(false),
|
|
Workflows: map[string]raw.Workflow{
|
|
"test-dev": {
|
|
Plan: &raw.Stage{
|
|
Steps: []raw.Step{
|
|
{
|
|
Key: ptr("init"),
|
|
},
|
|
{
|
|
Map: map[string]map[string][]string{
|
|
"plan": {"extra_args": []string{"-var-file=vars/dev.tfvars"}},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Apply: &raw.Stage{
|
|
Steps: []raw.Step{
|
|
{
|
|
Key: ptr("apply"),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"test-stg": {
|
|
Plan: &raw.Stage{
|
|
Steps: []raw.Step{
|
|
{
|
|
Key: ptr("init"),
|
|
},
|
|
{
|
|
Map: map[string]map[string][]string{
|
|
"plan": {"extra_args": []string{"-var-file=vars/nested/stg.tfvars"}},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Apply: &raw.Stage{
|
|
Steps: []raw.Step{
|
|
{
|
|
Key: ptr("apply"),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
Projects: []raw.Project{
|
|
{
|
|
Name: ptr("test-dev"),
|
|
Dir: ptr("test"),
|
|
Workflow: ptr("test-dev"),
|
|
},
|
|
{
|
|
Name: ptr("test-stg"),
|
|
Dir: ptr("test"),
|
|
Workflow: ptr("test-stg"),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tc := range tests {
|
|
got, _ := NewRepoCfg(tc.components, Options{})
|
|
if !cmp.Equal(got, tc.want) {
|
|
t.Errorf(`NewFrom()
|
|
diff %s`, cmp.Diff(got, tc.want))
|
|
}
|
|
}
|
|
}
|