Skip to content

Commit c37fbe4

Browse files
committed
refactor: move Step StepActionReference test
Now that `Step` implements the `Validatable` interface the tests for the `Step` validation are moved from `task_validation_test.go` to `container_validation_test.go`. The following tests is moved and renamed: - `TestTaskSpecStepActionReferenceValidate` - `TestStepWithStepActionReferenceValidate` Issue #8700. Signed-off-by: Stanislav Jakuschevskij <[email protected]>
1 parent e97fed6 commit c37fbe4

File tree

2 files changed

+37
-37
lines changed

2 files changed

+37
-37
lines changed

pkg/apis/pipeline/v1/container_validation_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,43 @@ func TestRef_Invalid(t *testing.T) {
171171
}
172172
}
173173

174+
func TestStepWithStepActionReferenceValidate(t *testing.T) {
175+
tests := []struct {
176+
name string
177+
Step v1.Step
178+
}{{
179+
name: "valid stepAction ref",
180+
Step: v1.Step{
181+
Name: "mystep",
182+
Ref: &v1.Ref{
183+
Name: "stepAction",
184+
},
185+
},
186+
}, {
187+
name: "valid use of params with Ref",
188+
Step: v1.Step{
189+
Ref: &v1.Ref{
190+
Name: "stepAction",
191+
},
192+
Params: v1.Params{{
193+
Name: "param",
194+
}},
195+
},
196+
}}
197+
for _, st := range tests {
198+
t.Run(st.name, func(t *testing.T) {
199+
ctx := config.ToContext(context.Background(), &config.Config{
200+
FeatureFlags: &config.FeatureFlags{
201+
EnableStepActions: true,
202+
},
203+
})
204+
if err := st.Step.Validate(ctx); err != nil {
205+
t.Errorf("Step.Validate() = %v", err)
206+
}
207+
})
208+
}
209+
}
210+
174211
func TestSidecarValidate(t *testing.T) {
175212
tests := []struct {
176213
name string

pkg/apis/pipeline/v1/task_validation_test.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -557,43 +557,6 @@ func TestTaskSpecValidate(t *testing.T) {
557557
}
558558
}
559559

560-
func TestTaskSpecStepActionReferenceValidate(t *testing.T) {
561-
tests := []struct {
562-
name string
563-
Steps []v1.Step
564-
}{{
565-
name: "valid stepaction ref",
566-
Steps: []v1.Step{{
567-
Name: "mystep",
568-
Ref: &v1.Ref{
569-
Name: "stepAction",
570-
},
571-
}},
572-
}, {
573-
name: "valid use of params with Ref",
574-
Steps: []v1.Step{{
575-
Ref: &v1.Ref{
576-
Name: "stepAction",
577-
},
578-
Params: v1.Params{{
579-
Name: "param",
580-
}},
581-
}},
582-
}}
583-
for _, tt := range tests {
584-
t.Run(tt.name, func(t *testing.T) {
585-
ts := &v1.TaskSpec{
586-
Steps: tt.Steps,
587-
}
588-
ctx := context.Background()
589-
ts.SetDefaults(ctx)
590-
if err := ts.Validate(ctx); err != nil {
591-
t.Errorf("TaskSpec.Validate() = %v", err)
592-
}
593-
})
594-
}
595-
}
596-
597560
func TestTaskValidateError(t *testing.T) {
598561
type fields struct {
599562
Params []v1.ParamSpec

0 commit comments

Comments
 (0)