Skip to content

Commit

Permalink
fix(engine): use default value for hidden options (#73)
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Brumhard <tobias.brumhard@mail.schwarz>
  • Loading branch information
brumhard authored Feb 11, 2022
1 parent 4cdf06f commit bececbe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/gotemplate/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (gt *GT) LoadConfigValuesInteractively() (*OptionValues, error) {

func (gt *GT) loadOptionValueInteractively(option *Option, optionValues *OptionValues) interface{} {
if !option.ShouldDisplay(optionValues) {
return nil
return option.Default(optionValues)
}

val, err := gt.readOptionValue(option, optionValues)
Expand Down
3 changes: 2 additions & 1 deletion pkg/gotemplate/new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ func TestGT_LoadConfigValuesInteractively(t *testing.T) {

optionValues, err := gt.LoadConfigValuesInteractively()
require.NoError(t, err)
require.Equal(t, len(optionValues.Base), 0)
// the default value should be used in the optionValues in case there are dependent options
require.Equal(t, len(optionValues.Base), 1)
require.NotContains(t, out.String(), dependentOptionName)
})

Expand Down

0 comments on commit bececbe

Please sign in to comment.