mirror of
https://github.com/actions/setup-python.git
synced 2025-04-21 22:38:43 +00:00
Amend unit tests
This commit is contained in:
parent
2dd90ca26f
commit
e6b5cf91d5
1 changed files with 17 additions and 3 deletions
|
@ -2,6 +2,7 @@ import * as core from '@actions/core';
|
|||
import * as cache from '@actions/cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import {getCacheDistributor} from '../src/cache-distributions/cache-factory';
|
||||
import * as utils from './../src/utils';
|
||||
|
||||
describe('restore-cache', () => {
|
||||
const pipFileLockHash =
|
||||
|
@ -27,6 +28,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
let debugSpy: jest.SpyInstance;
|
||||
let saveSatetSpy: jest.SpyInstance;
|
||||
let getStateSpy: jest.SpyInstance;
|
||||
let computeKeysSpy: jest.SpyInstance;
|
||||
let setOutputSpy: jest.SpyInstance;
|
||||
|
||||
// cache spy
|
||||
|
@ -74,6 +76,8 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
return primaryKey;
|
||||
}
|
||||
);
|
||||
|
||||
computeKeysSpy = jest.spyOn(utils, 'getLinuxOSReleaseInfo');
|
||||
});
|
||||
|
||||
describe('Validate provided package manager', () => {
|
||||
|
@ -109,11 +113,21 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
|
|||
pythonVersion,
|
||||
dependencyFile
|
||||
);
|
||||
|
||||
if (process.env['RUNNER_OS'] === 'linux') {
|
||||
computeKeysSpy.mockImplementation(() => 'Ubuntu-20.4');
|
||||
}
|
||||
await cacheDistributor.restoreCache();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||
);
|
||||
if (process.env['RUNNER_OS'] === 'linux') {
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-Ubuntu-20.4-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||
);
|
||||
} else {
|
||||
expect(infoSpy).toHaveBeenCalledWith(
|
||||
`Cache restored from key: setup-python-${process.env['RUNNER_OS']}-python-${pythonVersion}-${packageManager}-${fileHash}`
|
||||
);
|
||||
}
|
||||
},
|
||||
30000
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue