feature: add version parsing from Pipfile

This commit is contained in:
Aramís Segovia 2025-03-26 22:46:53 -04:00
parent 1264885983
commit 9485ba7ca7
5 changed files with 222 additions and 3 deletions

View file

@ -12,6 +12,7 @@ import {
getVersionInputFromFile,
getVersionsInputFromPlainFile,
getVersionInputFromTomlFile,
getVersionInputFromPipfileFile,
getNextPageUrl,
isGhes,
IS_WINDOWS,
@ -244,6 +245,44 @@ describe('Version from file test', () => {
expect(_fn(toolVersionFilePath)).toEqual(['3.14t-dev']);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13';
const pythonVersionFileContent = `[requires]\npython_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Version from python_full_version in Pipfile',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersion = '3.13.0';
const pythonVersionFileContent = `[requires]\npython_full_version = "${pythonVersion}"`;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([pythonVersion]);
}
);
it.each([getVersionInputFromPipfileFile, getVersionInputFromFile])(
'Pipfile undefined version',
async _fn => {
await io.mkdirP(tempDir);
const pythonVersionFileName = 'Pipfile';
const pythonVersionFilePath = path.join(tempDir, pythonVersionFileName);
const pythonVersionFileContent = ``;
fs.writeFileSync(pythonVersionFilePath, pythonVersionFileContent);
expect(_fn(pythonVersionFilePath)).toEqual([]);
}
);
});
describe('getNextPageUrl', () => {