Skip to content

Commit 07385a4

Browse files
committed
help mock
1 parent d4c047b commit 07385a4

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/managers/builtin/helpers.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export function resetUvInstallationCache(): void {
1616
}
1717

1818
export async function isUvInstalled(log?: LogOutputChannel): Promise<boolean> {
19+
console.log('into isUvInstalled function');
1920
if (available.completed) {
21+
console.log('UV installation status already determined');
2022
return available.promise;
2123
}
2224
log?.info(`Running: uv --version`);
@@ -61,6 +63,7 @@ export async function shouldUseUv(log?: LogOutputChannel, envPath?: string): Pro
6163
console.log(config.inspect<boolean>('alwaysUseUv')?.globalValue);
6264

6365
if (alwaysUseUv) {
66+
console.log(`alwaysUseUv is true, checking if UV is installed`);
6467
return await isUvInstalled(log);
6568
}
6669
return false;

src/test/managers/builtin/helpers.shouldUseUv.unit.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { LogOutputChannel } from 'vscode';
44
import * as persistentState from '../../../common/persistentState';
55
import * as workspaceApis from '../../../common/workspace.apis';
66
import * as helpers from '../../../managers/builtin/helpers';
7-
import { shouldUseUv } from '../../../managers/builtin/helpers';
87
import * as uvEnvironments from '../../../managers/builtin/uvEnvironments';
98

109
interface MockWorkspaceConfig {
@@ -79,15 +78,15 @@ suite('Helpers - shouldUseUv', () => {
7978
globalLocalValue: true,
8079
globalValue: true,
8180
};
82-
81+
8382
mockConfig.get.withArgs('alwaysUseUv', true).returns(true);
8483
mockConfig.get.withArgs('alwaysUseUv').returns(true);
8584
mockConfig.inspect.withArgs('alwaysUseUv').returns(mockInspectResult);
8685
isUvInstalledStub.resolves(true);
8786
getUvEnvironmentsStub.resolves([]);
8887

8988
// Run
90-
const result = await shouldUseUv(mockLog);
89+
const result = await helpers.shouldUseUv(mockLog);
9190

9291
// Assert - Should return true when setting is true and UV is installed
9392
assert.strictEqual(result, true);
@@ -99,7 +98,7 @@ suite('Helpers - shouldUseUv', () => {
9998
getUvEnvironmentsStub.resolves([]);
10099

101100
// Run
102-
const result = await shouldUseUv(mockLog);
101+
const result = await helpers.shouldUseUv(mockLog);
103102

104103
// Assert - Should not use UV when setting is false
105104
assert.strictEqual(result, false);
@@ -113,7 +112,7 @@ suite('Helpers - shouldUseUv', () => {
113112
mockConfig.get.withArgs('alwaysUseUv', true).returns(false);
114113

115114
// Run
116-
const result = await shouldUseUv(mockLog, uvEnvPath);
115+
const result = await helpers.shouldUseUv(mockLog, uvEnvPath);
117116

118117
// Assert - Should return true for UV environments when UV is installed
119118
assert.strictEqual(result, true);
@@ -126,7 +125,7 @@ suite('Helpers - shouldUseUv', () => {
126125
getUvEnvironmentsStub.resolves([]);
127126

128127
// Run
129-
const result = await shouldUseUv(mockLog, nonUvEnvPath);
128+
const result = await helpers.shouldUseUv(mockLog, nonUvEnvPath);
130129

131130
// Assert - Should not use UV for non-UV environments when setting is false
132131
assert.strictEqual(result, false);
@@ -140,7 +139,7 @@ suite('Helpers - shouldUseUv', () => {
140139
getUvEnvironmentsStub.resolves([]);
141140

142141
// Run
143-
const result = await shouldUseUv(mockLog, nonUvEnvPath);
142+
const result = await helpers.shouldUseUv(mockLog, nonUvEnvPath);
144143

145144
// Assert - Should return true when alwaysUseUv is true and UV is installed
146145
assert.strictEqual(result, true);

0 commit comments

Comments
 (0)