Skip to content

Commit

Permalink
tests: Fix TestAskWorkflowsOptionsByFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
michaljurecko committed Feb 22, 2024
1 parent b7e62b6 commit a607fbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions internal/pkg/service/cli/cmd/ci/workflow/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type Flags struct {
CIPush configmap.Value[bool] `configKey:"ci-push" configUsage:"create workflow to push change in main branch to the project"`
}

func DefaultFlags() *Flags {
return &Flags{
func DefaultFlags() Flags {
return Flags{
CI: configmap.NewValue(true),
CIValidate: configmap.NewValue(true),
CIPush: configmap.NewValue(true),
Expand All @@ -35,8 +35,8 @@ func WorkflowsCommand(p dependencies.Provider) *cobra.Command {
Short: helpmsg.Read(`ci/workflows/short`),
Long: helpmsg.Read(`ci/workflows/long`),
RunE: func(cmd *cobra.Command, args []string) (err error) {
// Bind flags to struct
f := DefaultFlags()
// bind flags to struct
if err := configmap.Bind(utils.GetBindConfig(cmd.Flags(), args), f); err != nil {
return err
}
Expand All @@ -52,7 +52,7 @@ func WorkflowsCommand(p dependencies.Provider) *cobra.Command {
}

// Ask options
options := AskWorkflowsOptions(*f, d.Dialogs())
options := AskWorkflowsOptions(f, d.Dialogs())

// Generate workflows
return workflowsGen.Run(cmd.Context(), prj.Fs(), options, d)
Expand Down
13 changes: 6 additions & 7 deletions internal/pkg/service/cli/dialog/workflows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestAskWorkflowsOptionsInteractive(t *testing.T) {
}()

// Run
out := workflow.AskWorkflowsOptions(*f, dialog)
out := workflow.AskWorkflowsOptions(f, dialog)
assert.Equal(t, genWorkflows.Options{
Validate: false,
Push: true,
Expand All @@ -67,12 +67,11 @@ func TestAskWorkflowsOptionsByFlag(t *testing.T) {
o.Set(`ci-pull`, `false`)
o.Set(`ci-main-branch`, `main`)

f := workflow.Flags{
CIValidate: configmap.NewValue(false),
CIPull: configmap.NewValue(false),
CIMainBranch: configmap.NewValue("main"),
CIPush: configmap.NewValue(true),
}
f := workflow.DefaultFlags()
f.CIValidate = configmap.NewValueWithOrigin(false, configmap.SetByFlag)
f.CIPull = configmap.NewValueWithOrigin(false, configmap.SetByFlag)
f.CIMainBranch = configmap.NewValueWithOrigin("main", configmap.SetByFlag)
f.CIPush = configmap.NewValueWithOrigin(true, configmap.SetByFlag)

// Run
out := workflow.AskWorkflowsOptions(f, dialog)
Expand Down

0 comments on commit a607fbf

Please sign in to comment.