X Tutup
Skip to content

Commit ce8f66b

Browse files
authored
Have extension upgrade --all be non-fatal when no extensions installed (cli#5356)
1 parent 91c450e commit ce8f66b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pkg/cmd/extension/command.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ func NewCmdExtension(f *cmdutil.Factory) *cobra.Command {
153153
if err != nil && !errors.Is(err, upToDateError) {
154154
if name != "" {
155155
fmt.Fprintf(io.ErrOut, "%s Failed upgrading extension %s: %s\n", cs.FailureIcon(), name, err)
156+
} else if errors.Is(err, noExtensionsInstalledError) {
157+
fmt.Fprintf(io.ErrOut, "%s No installed extensions found\n", cs.WarningIcon())
158+
return nil
156159
} else {
157160
fmt.Fprintf(io.ErrOut, "%s Failed upgrading extensions\n", cs.FailureIcon())
158161
}

pkg/cmd/extension/command_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ func TestNewCmdExtension(t *testing.T) {
207207
isTTY: true,
208208
wantStdout: "✓ Successfully upgraded extensions\n",
209209
},
210+
{
211+
name: "upgrade all none installed",
212+
args: []string{"upgrade", "--all"},
213+
managerStubs: func(em *extensions.ExtensionManagerMock) func(*testing.T) {
214+
em.UpgradeFunc = func(name string, force bool) error {
215+
return noExtensionsInstalledError
216+
}
217+
return func(t *testing.T) {
218+
calls := em.UpgradeCalls()
219+
assert.Equal(t, 1, len(calls))
220+
assert.Equal(t, "", calls[0].Name)
221+
}
222+
},
223+
isTTY: true,
224+
wantStderr: "! No installed extensions found\n",
225+
},
210226
{
211227
name: "upgrade all notty",
212228
args: []string{"upgrade", "--all"},

0 commit comments

Comments
 (0)
X Tutup