diff --git a/extensions/podman/src/extension.spec.ts b/extensions/podman/src/extension.spec.ts index 8ca6997f4d8..407d0ec1c96 100644 --- a/extensions/podman/src/extension.spec.ts +++ b/extensions/podman/src/extension.spec.ts @@ -1088,3 +1088,29 @@ test('checkDisguisedPodmanSocket: runs updateWarnings when called not on Linux', await checkDisguisedPodmanSocket(provider); expect(updateWarningsMock).toBeCalled(); }); + +test('Even with getJSONMachineList erroring, do not show setup notification on Linux', async () => { + vi.mocked(isLinux).mockReturnValue(true); + vi.spyOn(extensionApi.process, 'exec').mockRejectedValue({ + name: 'name', + message: 'description', + stderr: 'error', + }); + await expect(extension.updateMachines(provider)).rejects.toThrow('description'); + expect(extensionApi.window.showNotification).not.toBeCalled(); +}); + +test('If machine list is empty, do not show setup notification on Linux', async () => { + vi.mocked(isLinux).mockReturnValue(true); + const spyExecPromise = vi.spyOn(extensionApi.process, 'exec'); + spyExecPromise.mockResolvedValue({ stdout: '[]' } as extensionApi.RunResult); + await extension.updateMachines(provider); + expect(extensionApi.window.showNotification).not.toBeCalled(); +}); + +test('if there are no machines, make sure checkDefaultMachine is not being ran inside updateMachines', async () => { + const spyCheckDefaultMachine = vi.spyOn(extension, 'checkDefaultMachine'); + vi.spyOn(extensionApi.process, 'exec').mockResolvedValue({ stdout: '[]' } as extensionApi.RunResult); + await extension.updateMachines(provider); + expect(spyCheckDefaultMachine).not.toBeCalled(); +}); diff --git a/extensions/podman/src/extension.ts b/extensions/podman/src/extension.ts index 083ec46fa8e..422178de3ff 100644 --- a/extensions/podman/src/extension.ts +++ b/extensions/podman/src/extension.ts @@ -125,7 +125,9 @@ export async function updateMachines(provider: extensionApi.Provider): Promise 0, 'onboarding'); - if (shouldNotifySetup && machines.length === 0) { + + // Only show the notification on macOS and Windows + // as Podman is already installed on Linux and machine is OPTIONAL. + if (shouldNotifySetup && machines.length === 0 && !isLinux()) { // push setup notification notificationDisposable = extensionApi.window.showNotification(setupPodmanNotification); shouldNotifySetup = false; @@ -260,29 +265,35 @@ export async function updateMachines(provider: extensionApi.Provider): Promise machine.Running); - const atLeastOneMachineStarting = machines.some(machine => machine.Starting); - // if a machine is running it's started else it is ready - if (atLeastOneMachineRunning) { - provider.updateStatus('ready'); - } else if (atLeastOneMachineStarting) { - // update to starting - provider.updateStatus('starting'); } else { - // needs to start a machine - provider.updateStatus('configured'); + const atLeastOneMachineRunning = machines.some(machine => machine.Running); + const atLeastOneMachineStarting = machines.some(machine => machine.Starting); + // if a machine is running it's started else it is ready + if (atLeastOneMachineRunning) { + provider.updateStatus('ready'); + } else if (atLeastOneMachineStarting) { + // update to starting + provider.updateStatus('starting'); + } else { + // needs to start a machine + provider.updateStatus('configured'); + } } } // Finally, we check to see if the machine that is running is set by default or not on the CLI // this will create a dialog that will ask the user if they wish to set the running machine as default. - await checkDefaultMachine(machines); + // this should only run if we have multiple machines + if (machines.length > 1) { + await checkDefaultMachine(machines); + } } export async function checkDefaultMachine(machines: MachineJSON[]): Promise {