Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/state-installer/test/integration/installer_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ func (suite *InstallerIntegrationTestSuite) TestInstallFromLocalSource() {

// Assert output
cp.Expect("Installing State Tool")
if runtime.GOOS == "windows" {
cp.Expect("Continuing because State Tool is running in non-interactive mode") // admin prompt
}
cp.Expect("Done")
cp.Expect("successfully installed")
suite.NotContains(cp.Output(), "Downloading State Tool")
Expand Down
12 changes: 3 additions & 9 deletions internal/prompt/prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string
if nonInteractiveResponse == nil {
return "", ErrNoForceOption
}
}

if !p.isInteractive {
} else if !p.isInteractive {
Copy link
Collaborator Author

@mitchell-as mitchell-as Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug here is that we were checking for force and setting nonInteractiveResponse but if !p.isInteractive is also true (it's usually not), then the nonInteractiveResponse we just set would be overwritten with a different value. Oops.

Same applies to the other changes in this PR.

nonInteractiveResponse = defaultResponse
if nonInteractiveResponse == nil {
return "", interactiveInputError(message)
Expand Down Expand Up @@ -194,9 +192,7 @@ func (p *Prompt) Select(title, message string, choices []string, defaultChoice *
if nonInteractiveChoice == nil {
return "", ErrNoForceOption
}
}

if !p.isInteractive {
} else if !p.isInteractive {
nonInteractiveChoice = defaultChoice
if nonInteractiveChoice == nil {
return "", interactiveInputError(message)
Expand Down Expand Up @@ -253,9 +249,7 @@ func (p *Prompt) Confirm(title, message string, defaultChoice *bool, forcedChoic
if nonInteractiveChoice == nil {
return false, ErrNoForceOption
}
}

if !p.isInteractive {
} else if !p.isInteractive {
nonInteractiveChoice = defaultChoice
if nonInteractiveChoice == nil {
return false, interactiveInputError(message)
Expand Down
3 changes: 3 additions & 0 deletions test/integration/install_scripts_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (suite *InstallScriptsIntegrationTestSuite) TestInstall() {
}
cp := ts.SpawnCmdWithOpts(cmd, opts...)
cp.Expect("Preparing Installer for State Tool Package Manager")
if runtime.GOOS == "windows" {
cp.Expect("Continuing because the '--force' flag is set") // admin prompt
}
cp.Expect("Installation Complete", e2e.RuntimeSourcingTimeoutOpt)

if tt.Activate != "" || tt.ActivateByCommand != "" {
Expand Down
Loading