From ed1b43d50154b1513f207e2bd0ca4ad000b61f65 Mon Sep 17 00:00:00 2001 From: Karthik Nadig Date: Thu, 17 Oct 2024 12:16:48 -0700 Subject: [PATCH] Fix terminal helper tests --- src/test/common/terminals/helper.unit.test.ts | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/test/common/terminals/helper.unit.test.ts b/src/test/common/terminals/helper.unit.test.ts index e4a0ab9bd3e8..864188b7c7b4 100644 --- a/src/test/common/terminals/helper.unit.test.ts +++ b/src/test/common/terminals/helper.unit.test.ts @@ -211,8 +211,8 @@ suite('Terminal Service helpers', () => { const cmd = await helper.getEnvironmentActivationCommands(anything(), resource); expect(cmd).to.equal(condaActivationCommands); - verify(pythonSettings.pythonPath).once(); - verify(condaService.isCondaEnvironment(pythonPath)).once(); + verify(pythonSettings.pythonPath).atLeast(1); + verify(condaService.isCondaEnvironment(pythonPath)).atLeast(1); verify(condaActivationProvider.getActivationCommands(resource, anything())).once(); }); test('Activation command must return undefined if none of the proivders support the shell', async () => { @@ -231,8 +231,8 @@ suite('Terminal Service helpers', () => { ); expect(cmd).to.equal(undefined, 'Command must be undefined'); - verify(pythonSettings.pythonPath).once(); - verify(condaService.isCondaEnvironment(pythonPath)).once(); + verify(pythonSettings.pythonPath).atLeast(1); + verify(condaService.isCondaEnvironment(pythonPath)).atLeast(1); verify(bashActivationProvider.isShellSupported(anything())).atLeast(1); verify(nushellActivationProvider.isShellSupported(anything())).atLeast(1); verify(pyenvActivationProvider.isShellSupported(anything())).atLeast(1); @@ -255,8 +255,8 @@ suite('Terminal Service helpers', () => { const cmd = await helper.getEnvironmentActivationCommands(anything(), resource); expect(cmd).to.deep.equal(expectCommand); - verify(pythonSettings.pythonPath).once(); - verify(condaService.isCondaEnvironment(pythonPath)).once(); + verify(pythonSettings.pythonPath).atLeast(1); + verify(condaService.isCondaEnvironment(pythonPath)).atLeast(1); verify(bashActivationProvider.isShellSupported(anything())).atLeast(1); verify(bashActivationProvider.getActivationCommands(resource, anything())).once(); verify(nushellActivationProvider.isShellSupported(anything())).atLeast(1); @@ -287,7 +287,7 @@ suite('Terminal Service helpers', () => { const cmd = await helper.getEnvironmentActivationCommands(anything(), resource); expect(cmd).to.deep.equal(expectCommand); - verify(pythonSettings.pythonPath).once(); + verify(pythonSettings.pythonPath).atLeast(1); verify(condaService.isCondaEnvironment(pythonPath)).once(); verify(bashActivationProvider.isShellSupported(anything())).atLeast(1); verify(bashActivationProvider.getActivationCommands(resource, anything())).never(); @@ -313,7 +313,7 @@ suite('Terminal Service helpers', () => { const cmd = await helper.getEnvironmentActivationCommands(anything(), resource); expect(cmd).to.deep.equal(expectCommand); - verify(pythonSettings.pythonPath).once(); + verify(pythonSettings.pythonPath).atLeast(1); verify(condaService.isCondaEnvironment(pythonPath)).once(); verify(bashActivationProvider.isShellSupported(anything())).atLeast(1); verify(nushellActivationProvider.isShellSupported(anything())).atLeast(1); @@ -340,7 +340,7 @@ suite('Terminal Service helpers', () => { const cmd = await helper.getEnvironmentActivationCommands(anything(), resource); expect(cmd).to.deep.equal(expectCommand); - verify(pythonSettings.pythonPath).once(); + verify(pythonSettings.pythonPath).atLeast(1); verify(condaService.isCondaEnvironment(pythonPath)).once(); verify(bashActivationProvider.getActivationCommands(resource, anything())).once(); verify(cmdActivationProvider.getActivationCommands(resource, anything())).once(); @@ -387,8 +387,13 @@ suite('Terminal Service helpers', () => { ); expect(cmd).to.equal(undefined, 'Command must be undefined'); - verify(pythonSettings.pythonPath).times(interpreter ? 0 : 1); - verify(condaService.isCondaEnvironment(pythonPath)).times(interpreter ? 0 : 1); + if (interpreter) { + verify(pythonSettings.pythonPath).never(); + verify(condaService.isCondaEnvironment(pythonPath)).never(); + } else { + verify(pythonSettings.pythonPath).atLeast(1); + verify(condaService.isCondaEnvironment(pythonPath)).atLeast(1); + } verify(bashActivationProvider.isShellSupported(shellToExpect)).atLeast(1); verify(pyenvActivationProvider.isShellSupported(anything())).never(); verify(pipenvActivationProvider.isShellSupported(anything())).never();