|
1 | 1 | import assert from 'assert'; |
2 | 2 | import * as path from 'path'; |
3 | 3 | import * as sinon from 'sinon'; |
4 | | -import { CancellationToken, LogOutputChannel, Progress, ProgressOptions, Uri } from 'vscode'; |
| 4 | +import { CancellationToken, LogOutputChannel, Progress, ProgressLocation, ProgressOptions, Uri } from 'vscode'; |
5 | 5 | import * as fse from 'fs-extra'; |
6 | 6 | import * as os from 'os'; |
7 | 7 | import { PythonEnvironment, PythonEnvironmentApi, PythonProject } from '../../../api'; |
@@ -87,6 +87,35 @@ suite('Pip Utils - getProjectInstallable', () => { |
87 | 87 | assert.ok(logError.calledOnceWithExactly('Error listing installed packages', listError)); |
88 | 88 | assert.ok(showQuickPick.calledOnce, 'The package picker should still open after a list failure'); |
89 | 89 | }); |
| 90 | + |
| 91 | + test('shows progress while listing installed packages', async () => { |
| 92 | + const environment = { |
| 93 | + environmentPath: Uri.file('.'), |
| 94 | + execInfo: { run: { executable: 'python' } }, |
| 95 | + } as PythonEnvironment; |
| 96 | + const workspacePath = Uri.file('/test/path/root').fsPath; |
| 97 | + findFilesStub.callsFake((pattern: string) => |
| 98 | + Promise.resolve( |
| 99 | + pattern === '*requirements*.txt' |
| 100 | + ? [Uri.file(path.join(workspacePath, 'requirements.txt'))] |
| 101 | + : [], |
| 102 | + ), |
| 103 | + ); |
| 104 | + sinon.stub(helpers, 'shouldUseUv').resolves(false); |
| 105 | + sinon.stub(PipListCommand.prototype, 'execute').resolves([]); |
| 106 | + const showQuickPick = sinon.stub(winapi, 'showQuickPickWithButtons').resolves(undefined); |
| 107 | + |
| 108 | + await getWorkspacePackagesToInstall( |
| 109 | + mockApi as PythonEnvironmentApi, |
| 110 | + { install: [] }, |
| 111 | + [{ name: 'workspace', uri: Uri.file(workspacePath) }], |
| 112 | + environment, |
| 113 | + ); |
| 114 | + |
| 115 | + assert.strictEqual(withProgressStub.callCount, 2); |
| 116 | + assert.strictEqual(withProgressStub.secondCall.args[0].location, ProgressLocation.Notification); |
| 117 | + assert.ok(withProgressStub.secondCall.calledBefore(showQuickPick.firstCall)); |
| 118 | + }); |
90 | 119 | }); |
91 | 120 |
|
92 | 121 | teardown(() => { |
|
0 commit comments