Skip to content

Commit

Permalink
schema loading tests
Browse files Browse the repository at this point in the history
Signed-off-by: Gerd Oberlechner <[email protected]>
  • Loading branch information
geoberle committed Dec 5, 2024
1 parent 926c6c3 commit 751354a
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 143 deletions.
143 changes: 0 additions & 143 deletions tooling/templatize/pkg/pipeline/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,149 +35,6 @@ func TestStepRunSkip(t *testing.T) {
assert.Error(t, err, "unsupported action type \"\"")
}

func TestRGValidate(t *testing.T) {
testCases := []struct {
name string
rg *ResourceGroup
err string
}{
{
name: "missing name",
rg: &ResourceGroup{},
err: "resource group name is required",
},
{
name: "missing subscription",
rg: &ResourceGroup{Name: "test"},
err: "subscription is required",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.rg.Validate()
assert.Error(t, err, tc.err)
})
}

}

func TestPipelineValidate(t *testing.T) {
testCases := []struct {
name string
pipeline *Pipeline
err string
}{
{
name: "missing name",
pipeline: &Pipeline{
ResourceGroups: []*ResourceGroup{{}},
},
err: "resource group name is required",
},
{
name: "missing subscription",
pipeline: &Pipeline{
ResourceGroups: []*ResourceGroup{
{
Name: "rg",
},
},
},
err: "subscription is required",
},
{
name: "missing step dependency",
pipeline: &Pipeline{
ResourceGroups: []*ResourceGroup{
{
Name: "rg1",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step1",
},
},
},
{
Name: "rg2",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step2",
DependsOn: []string{"step3"},
},
},
},
},
},
err: "invalid dependency on step step2: dependency step3 does not exist",
},
{
name: "duplicate step name",
pipeline: &Pipeline{
ResourceGroups: []*ResourceGroup{
{
Name: "rg1",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step1",
},
},
},
{
Name: "rg2",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step1",
},
},
},
},
},
err: "duplicate step name \"step1\"",
},
{
name: "valid step dependencies",
pipeline: &Pipeline{
ResourceGroups: []*ResourceGroup{
{
Name: "rg1",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step1",
},
},
},
{
Name: "rg2",
Subscription: "sub1",
Steps: []*Step{
{
Name: "step2",
DependsOn: []string{"step1"},
},
},
},
},
},
err: "",
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.pipeline.Validate()
if tc.err == "" {
assert.NilError(t, err)
} else {
assert.Error(t, err, tc.err)
}
})
}
}

func TestResourceGroupRun(t *testing.T) {
foundOutput := ""
rg := &ResourceGroup{
Expand Down
Loading

0 comments on commit 751354a

Please sign in to comment.