Skip to content

Commit

Permalink
feat: want to test all cases for template test
Browse files Browse the repository at this point in the history
  • Loading branch information
hosekpeter committed Feb 14, 2025
1 parent 97e6093 commit 92e15c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions internal/pkg/service/cli/dialog/use_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (d *useTmplInputsDialog) ask(ctx context.Context, isForTest bool, inputsFil
err := d.groups.VisitInputs(func(group *input.StepsGroupExt, step *input.StepExt, inputDef *input.Input) error {
// Print info about group and select steps
if !group.Announced {
if err := d.announceGroup(group); err != nil {
if err := d.announceGroup(group, isForTest); err != nil {
return err
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func (d *useTmplInputsDialog) ask(ctx context.Context, isForTest bool, inputsFil
return d.out, warnings, err
}

func (d *useTmplInputsDialog) announceGroup(group *input.StepsGroupExt) error {
func (d *useTmplInputsDialog) announceGroup(group *input.StepsGroupExt, isForTest bool) error {
// Only once
if group.Announced {
return nil
Expand Down Expand Up @@ -147,8 +147,9 @@ func (d *useTmplInputsDialog) announceGroup(group *input.StepsGroupExt) error {
}
}
}
case !group.AreStepsSelectable():
case !group.AreStepsSelectable() || isForTest:
// Are all steps required? -> skip select box
// Want to test all cases for template test
for stepIndex := range group.Steps {
selectedSteps = append(selectedSteps, stepIndex)
}
Expand All @@ -173,7 +174,7 @@ func (d *useTmplInputsDialog) announceGroup(group *input.StepsGroupExt) error {
}

// Validate steps count
if err := group.ValidateStepsCount(len(group.Steps), len(selectedSteps)); err != nil {
if err := group.ValidateStepsCount(len(group.Steps), len(selectedSteps)); err != nil && !isForTest {
details := errors.NewMultiError()
details.Append(err)
details.Append(errors.Errorf("number of selected steps (%d) is incorrect", len(selectedSteps)))
Expand Down
4 changes: 2 additions & 2 deletions internal/pkg/template/test/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ func ReadInputValues(ctx context.Context, tmpl *template.Template, test *templat
inputValues := make(template.InputsValues, 0)
err = tmpl.Inputs().ToExtended().VisitInputs(func(group *input.StepsGroupExt, step *input.StepExt, inputDef *input.Input) error {
var inputValue template.InputValue
if v, found := inputsFile[inputDef.ID]; found {
inputValue, err = template.ParseInputValue(ctx, v, inputDef, true)
if value, found := inputsFile[inputDef.ID]; found {
inputValue, err = template.ParseInputValue(ctx, value, inputDef, true)
if err != nil {
return errors.NewNestedError(err, errors.New("please fix the value in the inputs JSON file"))
}
Expand Down

0 comments on commit 92e15c9

Please sign in to comment.