mirror of
https://github.com/actions/setup-python.git
synced 2025-04-24 23:42:13 +00:00
fix tests
This commit is contained in:
parent
381a73b90e
commit
62079dbf4b
3 changed files with 83 additions and 2 deletions
|
@ -63,6 +63,12 @@ describe('findPyPyToolCache', () => {
|
||||||
const pypyPath = path.join('PyPy', actualPythonVersion, architecture);
|
const pypyPath = path.join('PyPy', actualPythonVersion, architecture);
|
||||||
let tcFind: jest.SpyInstance;
|
let tcFind: jest.SpyInstance;
|
||||||
let spyReadExactPyPyVersion: jest.SpyInstance;
|
let spyReadExactPyPyVersion: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let addPathSpy: jest.SpyInstance;
|
||||||
|
let exportVariableSpy: jest.SpyInstance;
|
||||||
|
let setOutputSpy: jest.SpyInstance;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
tcFind = jest.spyOn(tc, 'find');
|
tcFind = jest.spyOn(tc, 'find');
|
||||||
|
@ -75,6 +81,24 @@ describe('findPyPyToolCache', () => {
|
||||||
|
|
||||||
spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile');
|
spyReadExactPyPyVersion = jest.spyOn(utils, 'readExactPyPyVersionFile');
|
||||||
spyReadExactPyPyVersion.mockImplementation(() => actualPyPyVersion);
|
spyReadExactPyPyVersion.mockImplementation(() => actualPyPyVersion);
|
||||||
|
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
addPathSpy = jest.spyOn(core, 'addPath');
|
||||||
|
addPathSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
exportVariableSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
exportVariableSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
setOutputSpy.mockImplementation(() => null);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
@ -118,7 +142,12 @@ describe('findPyPyToolCache', () => {
|
||||||
|
|
||||||
describe('findPyPyVersion', () => {
|
describe('findPyPyVersion', () => {
|
||||||
let getBooleanInputSpy: jest.SpyInstance;
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
let infoSpy: jest.SpyInstance;
|
let infoSpy: jest.SpyInstance;
|
||||||
|
let addPathSpy: jest.SpyInstance;
|
||||||
|
let exportVariableSpy: jest.SpyInstance;
|
||||||
|
let setOutputSpy: jest.SpyInstance;
|
||||||
let tcFind: jest.SpyInstance;
|
let tcFind: jest.SpyInstance;
|
||||||
let spyExtractZip: jest.SpyInstance;
|
let spyExtractZip: jest.SpyInstance;
|
||||||
let spyExtractTar: jest.SpyInstance;
|
let spyExtractTar: jest.SpyInstance;
|
||||||
|
@ -140,6 +169,21 @@ describe('findPyPyVersion', () => {
|
||||||
infoSpy = jest.spyOn(core, 'info');
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
infoSpy.mockImplementation(() => {});
|
infoSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
addPathSpy = jest.spyOn(core, 'addPath');
|
||||||
|
addPathSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
exportVariableSpy = jest.spyOn(core, 'exportVariable');
|
||||||
|
exportVariableSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
|
setOutputSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
tcFind = jest.spyOn(tc, 'find');
|
tcFind = jest.spyOn(tc, 'find');
|
||||||
tcFind.mockImplementation((tool: string, version: string) => {
|
tcFind.mockImplementation((tool: string, version: string) => {
|
||||||
const semverRange = new semver.Range(version);
|
const semverRange = new semver.Range(version);
|
||||||
|
|
|
@ -27,6 +27,13 @@ import * as installer from '../src/install-python';
|
||||||
const manifestData = require('./data/versions-manifest.json');
|
const manifestData = require('./data/versions-manifest.json');
|
||||||
|
|
||||||
describe('Finder tests', () => {
|
describe('Finder tests', () => {
|
||||||
|
let writeSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
writeSpy = jest.spyOn(process.stdout, 'write');
|
||||||
|
writeSpy.mockImplementation(() => {});
|
||||||
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
jest.resetAllMocks();
|
jest.resetAllMocks();
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import {HttpClient} from '@actions/http-client';
|
||||||
import * as ifm from '@actions/http-client/interfaces';
|
import * as ifm from '@actions/http-client/interfaces';
|
||||||
import * as tc from '@actions/tool-cache';
|
import * as tc from '@actions/tool-cache';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
|
import * as core from '@actions/core';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
import * as installer from '../src/install-pypy';
|
import * as installer from '../src/install-pypy';
|
||||||
|
@ -51,6 +52,22 @@ describe('findRelease', () => {
|
||||||
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}`
|
download_url: `https://test.download.python.org/pypy/pypy3.6-v7.3.3-${extensionName}`
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => null);
|
||||||
|
});
|
||||||
|
|
||||||
it("Python version is found, but PyPy version doesn't match", () => {
|
it("Python version is found, but PyPy version doesn't match", () => {
|
||||||
const pythonVersion = '3.6';
|
const pythonVersion = '3.6';
|
||||||
const pypyVersion = '7.3.7';
|
const pypyVersion = '7.3.7';
|
||||||
|
@ -133,6 +150,10 @@ describe('findRelease', () => {
|
||||||
|
|
||||||
describe('installPyPy', () => {
|
describe('installPyPy', () => {
|
||||||
let tcFind: jest.SpyInstance;
|
let tcFind: jest.SpyInstance;
|
||||||
|
let getBooleanInputSpy: jest.SpyInstance;
|
||||||
|
let warningSpy: jest.SpyInstance;
|
||||||
|
let debugSpy: jest.SpyInstance;
|
||||||
|
let infoSpy: jest.SpyInstance;
|
||||||
let spyExtractZip: jest.SpyInstance;
|
let spyExtractZip: jest.SpyInstance;
|
||||||
let spyExtractTar: jest.SpyInstance;
|
let spyExtractTar: jest.SpyInstance;
|
||||||
let spyFsReadDir: jest.SpyInstance;
|
let spyFsReadDir: jest.SpyInstance;
|
||||||
|
@ -158,6 +179,15 @@ describe('installPyPy', () => {
|
||||||
spyExtractTar = jest.spyOn(tc, 'extractTar');
|
spyExtractTar = jest.spyOn(tc, 'extractTar');
|
||||||
spyExtractTar.mockImplementation(() => tempDir);
|
spyExtractTar.mockImplementation(() => tempDir);
|
||||||
|
|
||||||
|
infoSpy = jest.spyOn(core, 'info');
|
||||||
|
infoSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
warningSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
|
debugSpy = jest.spyOn(core, 'debug');
|
||||||
|
debugSpy.mockImplementation(() => null);
|
||||||
|
|
||||||
spyFsReadDir = jest.spyOn(fs, 'readdirSync');
|
spyFsReadDir = jest.spyOn(fs, 'readdirSync');
|
||||||
spyFsReadDir.mockImplementation(() => ['PyPyTest']);
|
spyFsReadDir.mockImplementation(() => ['PyPyTest']);
|
||||||
|
|
||||||
|
@ -194,7 +224,7 @@ describe('installPyPy', () => {
|
||||||
|
|
||||||
it('throw if release is not found', async () => {
|
it('throw if release is not found', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
installer.installPyPy('7.3.3', '3.6.17', architecture)
|
installer.installPyPy('7.3.3', '3.6.17', architecture, undefined)
|
||||||
).rejects.toThrowError(
|
).rejects.toThrowError(
|
||||||
`PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found`
|
`PyPy version 3.6.17 (7.3.3) with arch ${architecture} not found`
|
||||||
);
|
);
|
||||||
|
@ -214,7 +244,7 @@ describe('installPyPy', () => {
|
||||||
spyChmodSync.mockImplementation(() => undefined);
|
spyChmodSync.mockImplementation(() => undefined);
|
||||||
|
|
||||||
await expect(
|
await expect(
|
||||||
installer.installPyPy('7.3.x', '3.6.12', architecture)
|
installer.installPyPy('7.3.x', '3.6.12', architecture, undefined)
|
||||||
).resolves.toEqual({
|
).resolves.toEqual({
|
||||||
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
|
installDir: path.join(toolDir, 'PyPy', '3.6.12', architecture),
|
||||||
resolvedPythonVersion: '3.6.12',
|
resolvedPythonVersion: '3.6.12',
|
||||||
|
|
Loading…
Add table
Reference in a new issue