Skip to content

Commit

Permalink
Fix tests for update-environment==false
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Jul 2, 2022
1 parent 78a2330 commit 412091c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions __tests__/find-pypy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ describe('findPyPyVersion', () => {
let spyChmodSync: jest.SpyInstance;
let spyCoreAddPath: jest.SpyInstance;
let spyCoreExportVariable: jest.SpyInstance;
const env = process.env;

beforeEach(() => {
jest.resetModules();
process.env = {...env};
tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation((tool: string, version: string) => {
const semverRange = new semver.Range(version);
Expand Down Expand Up @@ -214,6 +217,7 @@ describe('findPyPyVersion', () => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
process.env = env;
});

it('found PyPy in toolcache', async () => {
Expand Down
6 changes: 4 additions & 2 deletions __tests__/finder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,20 @@ const manifestData = require('./data/versions-manifest.json');
describe('Finder tests', () => {
let spyCoreAddPath: jest.SpyInstance;
let spyCoreExportVariable: jest.SpyInstance;
const env = process.env;

beforeEach(() => {
jest.resetModules();
process.env = {...env};
spyCoreAddPath = jest.spyOn(core, 'addPath');

spyCoreExportVariable = jest.spyOn(core, 'exportVariable');
});

afterEach(() => {
jest.resetAllMocks();
jest.clearAllMocks();
jest.restoreAllMocks();
process.env = env;
});

it('Finds Python if it is installed', async () => {
Expand Down Expand Up @@ -66,7 +69,6 @@ describe('Finder tests', () => {
await finder.useCpythonVersion('3.x', 'x64', false);
expect(spyCoreAddPath).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
expect(spyCoreExportVariable).not.toHaveBeenCalled();
});

it('Finds stable Python version if it is not installed, but exists in the manifest', async () => {
Expand Down

0 comments on commit 412091c

Please sign in to comment.