Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Nov 21, 2023
1 parent 073241b commit 5d9bbbf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/client/interpreter/autoSelection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class InterpreterAutoSelectionService implements IInterpreterAutoSelectio

private getAutoSelectionQueriedOnceState(): IPersistentState<boolean | undefined> {
const key = `autoSelectionInterpretersQueriedOnce`;
return this.stateFactory.createWorkspacePersistentState(key, undefined);
return this.stateFactory.createGlobalPersistentState(key, undefined);
}

/**
Expand Down
19 changes: 18 additions & 1 deletion src/test/interpreters/autoSelection/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ suite('Interpreters - Auto Selection', () => {
helper = mock(InterpreterHelper);
proxy = mock(InterpreterAutoSelectionProxyService);
interpreterService = mock(InterpreterService);
experimentService = mock(IExperimentService);
experimentService = mock<IExperimentService>();
when(experimentService.inExperimentSync(anything())).thenReturn(false);

const interpreterComparer = new EnvironmentTypeComparer(instance(helper));
Expand Down Expand Up @@ -144,6 +144,12 @@ suite('Interpreters - Auto Selection', () => {
undefined,
),
).thenReturn(instance(state));
when(
stateFactory.createGlobalPersistentState<PythonEnvironment | undefined>(
'autoSelectionInterpretersQueriedOnce',
undefined,
),
).thenReturn(instance(state));
when(workspaceService.getWorkspaceFolderIdentifier(anything(), '')).thenReturn('workspaceIdentifier');

autoSelectionService.onDidChangeAutoSelectedInterpreter(() => {
Expand Down Expand Up @@ -212,6 +218,13 @@ suite('Interpreters - Auto Selection', () => {

test('getInterpreters is called with ignoreCache at true if there is no value set in the workspace persistent state', async () => {
const interpreterComparer = new EnvironmentTypeComparer(instance(helper));

const globalQueriedState = mock(PersistentState) as PersistentState<boolean | undefined>;
when(globalQueriedState.value).thenReturn(true);
when(stateFactory.createGlobalPersistentState<boolean | undefined>(anyString(), undefined)).thenReturn(
instance(globalQueriedState),
);

const queryState = mock(PersistentState) as PersistentState<boolean | undefined>;

when(queryState.value).thenReturn(undefined);
Expand Down Expand Up @@ -393,6 +406,10 @@ suite('Interpreters - Auto Selection', () => {
when(stateFactory.createWorkspacePersistentState<boolean | undefined>(anyString(), undefined)).thenReturn(
instance(queryState),
);
when(queryState.value).thenReturn(undefined);
when(stateFactory.createGlobalPersistentState<boolean | undefined>(anyString(), undefined)).thenReturn(
instance(queryState),
);

let initialize = false;
let eventFired = false;
Expand Down

0 comments on commit 5d9bbbf

Please sign in to comment.