Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
treblereel committed Dec 2, 2024
1 parent c340be1 commit 373d4fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
7 changes: 5 additions & 2 deletions packages/kn-plugin-workflow/e2e-tests/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type cfgTestInputRun struct {
}

var cfgTestInputRun_Success = []cfgTestInputRun{
{input: command.RunCmdConfig{PortMapping: "8081", OpenDevUI: false}},
{input: command.RunCmdConfig{}},
{input: command.RunCmdConfig{PortMapping: "8081", OpenDevUI: false, StopContainerOnUserInput: false}},
{input: command.RunCmdConfig{StopContainerOnUserInput: false}},
}

func transformRunCmdCfgToArgs(cfg command.RunCmdConfig) []string {
Expand All @@ -56,6 +56,9 @@ func transformRunCmdCfgToArgs(cfg command.RunCmdConfig) []string {
if cfg.PortMapping != "" {
args = append(args, "--port", cfg.PortMapping)
}
if cfg.StopContainerOnUserInput {
args = append(args, "--stop-container-on-user-input=false")
}
return args
}

Expand Down
17 changes: 13 additions & 4 deletions packages/kn-plugin-workflow/pkg/command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
type RunCmdConfig struct {
PortMapping string
OpenDevUI bool
StopContainerOnUserInput bool
}

func NewRunCommand() *cobra.Command {
Expand All @@ -57,6 +58,10 @@ func NewRunCommand() *cobra.Command {
# Disable automatic browser launch of SonataFlow Dev UI
{{.Name}} run --open-dev-ui=false
# Stop the container when the user presses any key
{{.Name}} run --stop-container-on-user-input=false
`,
SuggestFor: []string{"rnu", "start"}, //nolint:misspell
PreRunE: common.BindEnv("port", "open-dev-ui"),
Expand All @@ -68,6 +73,7 @@ func NewRunCommand() *cobra.Command {

cmd.Flags().StringP("port", "p", "8080", "Maps a different host port to the running container port.")
cmd.Flags().Bool("open-dev-ui", true, "Disable automatic browser launch of SonataFlow Dev UI")
cmd.Flags().Bool("stop-container-on-user-input", true, "Stop the container when the user presses any key")
cmd.SetHelpFunc(common.DefaultTemplatedHelp)

return cmd
Expand All @@ -93,8 +99,9 @@ func run() error {

func runDevCmdConfig() (cfg RunCmdConfig, err error) {
cfg = RunCmdConfig{
PortMapping: viper.GetString("port"),
OpenDevUI: viper.GetBool("open-dev-ui"),
PortMapping: viper.GetString("port"),
OpenDevUI: viper.GetBool("open-dev-ui"),
StopContainerOnUserInput: viper.GetBool("stop-container-on-user-input"),
}
return
}
Expand Down Expand Up @@ -138,8 +145,10 @@ func runSWFProjectDevMode(containerTool string, cfg RunCmdConfig) (err error) {
pollInterval := 5 * time.Second
common.ReadyCheck(readyCheckURL, pollInterval, cfg.PortMapping, cfg.OpenDevUI)

if err := stopContainer(containerTool); err != nil {
return err
if cfg.StopContainerOnUserInput {
if err := stopContainer(containerTool); err != nil {
return err
}
}

wg.Wait()
Expand Down

0 comments on commit 373d4fa

Please sign in to comment.