Skip to content

Commit 370782b

Browse files
authored
Merge pull request #3616 from ActiveState/mitchell/dx-3193
Force prompt option should override non-interactive option.
2 parents 1bc3c37 + c72f478 commit 370782b

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

cmd/state-installer/test/integration/installer_int_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func (suite *InstallerIntegrationTestSuite) TestInstallFromLocalSource() {
4848

4949
// Assert output
5050
cp.Expect("Installing State Tool")
51+
if runtime.GOOS == "windows" {
52+
cp.Expect("Continuing because State Tool is running in non-interactive mode") // admin prompt
53+
}
5154
cp.Expect("Done")
5255
cp.Expect("successfully installed")
5356
suite.NotContains(cp.Output(), "Downloading State Tool")

internal/prompt/prompt.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ func (p *Prompt) InputAndValidate(title, message string, defaultResponse *string
129129
if nonInteractiveResponse == nil {
130130
return "", ErrNoForceOption
131131
}
132-
}
133-
134-
if !p.isInteractive {
132+
} else if !p.isInteractive {
135133
nonInteractiveResponse = defaultResponse
136134
if nonInteractiveResponse == nil {
137135
return "", interactiveInputError(message)
@@ -194,9 +192,7 @@ func (p *Prompt) Select(title, message string, choices []string, defaultChoice *
194192
if nonInteractiveChoice == nil {
195193
return "", ErrNoForceOption
196194
}
197-
}
198-
199-
if !p.isInteractive {
195+
} else if !p.isInteractive {
200196
nonInteractiveChoice = defaultChoice
201197
if nonInteractiveChoice == nil {
202198
return "", interactiveInputError(message)
@@ -253,9 +249,7 @@ func (p *Prompt) Confirm(title, message string, defaultChoice *bool, forcedChoic
253249
if nonInteractiveChoice == nil {
254250
return false, ErrNoForceOption
255251
}
256-
}
257-
258-
if !p.isInteractive {
252+
} else if !p.isInteractive {
259253
nonInteractiveChoice = defaultChoice
260254
if nonInteractiveChoice == nil {
261255
return false, interactiveInputError(message)

test/integration/install_scripts_int_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ func (suite *InstallScriptsIntegrationTestSuite) TestInstall() {
114114
}
115115
cp := ts.SpawnCmdWithOpts(cmd, opts...)
116116
cp.Expect("Preparing Installer for State Tool Package Manager")
117+
if runtime.GOOS == "windows" {
118+
cp.Expect("Continuing because the '--force' flag is set") // admin prompt
119+
}
117120
cp.Expect("Installation Complete", e2e.RuntimeSourcingTimeoutOpt)
118121

119122
if tt.Activate != "" || tt.ActivateByCommand != "" {

0 commit comments

Comments
 (0)