Skip to content

Commit

Permalink
Ensure dependency quick pick is not shown when user exits env creatio…
Browse files Browse the repository at this point in the history
…n. (#20605)

Fixes #20602
  • Loading branch information
karthiknadig authored Jan 31, 2023
1 parent 7fb72b7 commit 328e511
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export class VenvCreationProvider implements CreateEnvironmentProvider {
[EnvironmentType.System, EnvironmentType.MicrosoftStore, EnvironmentType.Global].includes(i.envType),
);

if (!interpreter) {
traceError('Virtual env creation requires an interpreter.');
return undefined;
}

let addGitIgnore = true;
let installPackages = true;
if (options) {
Expand All @@ -139,11 +144,6 @@ export class VenvCreationProvider implements CreateEnvironmentProvider {
}
const args = generateCommandArgs(installInfo, addGitIgnore);

if (!interpreter) {
traceError('Virtual env creation requires an interpreter.');
return undefined;
}

if (!installInfo) {
traceInfo('Virtual env creation exited during dependencies selection.');
return undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ suite('venv Creation provider tests', () => {

test('No workspace selected', async () => {
pickWorkspaceFolderStub.resolves(undefined);
interpreterQuickPick
.setup((i) => i.getInterpreterViaQuickPick(typemoq.It.isAny(), typemoq.It.isAny()))
.verifiable(typemoq.Times.never());

assert.isUndefined(await venvProvider.createEnvironment());
assert.isTrue(pickWorkspaceFolderStub.calledOnce);
interpreterQuickPick.verifyAll();
assert.isTrue(pickPackagesToInstallStub.notCalled);
});

test('No Python selected', async () => {
Expand All @@ -76,7 +81,10 @@ suite('venv Creation provider tests', () => {
.verifiable(typemoq.Times.once());

assert.isUndefined(await venvProvider.createEnvironment());

assert.isTrue(pickWorkspaceFolderStub.calledOnce);
interpreterQuickPick.verifyAll();
assert.isTrue(pickPackagesToInstallStub.notCalled);
});

test('User pressed Esc while selecting dependencies', async () => {
Expand Down

0 comments on commit 328e511

Please sign in to comment.