Add support to .tool-version file format

Create a function to parse tool-version (asdf-vm) format, add the
associated tests, and updated the documentation

Ticket-ID: #571
This commit is contained in:
Pablo Ifrán 2023-01-17 18:33:06 -03:00
parent bd6b4b6205
commit 892baae68b
4 changed files with 47 additions and 6 deletions

View file

@ -1,6 +1,7 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import {
parsePythonVersionFile,
validateVersion,
validatePythonVersionFormatForPyPy,
isCacheFeatureAvailable
@ -9,6 +10,20 @@ import {
jest.mock('@actions/cache');
jest.mock('@actions/core');
describe('parsePythonVersionFile', () => {
it('handle the content of a .python-version file', () => {
expect(parsePythonVersionFile('3.6')).toEqual('3.6')
});
it('trims extra spaces at the end of the content', () => {
expect(parsePythonVersionFile('3.7 ')).toEqual('3.7')
});
it('parses correctly the content of .tool-version files', () => {
expect(parsePythonVersionFile('python 3.7')).toEqual('3.7')
});
});
describe('validatePythonVersionFormatForPyPy', () => {
it.each([
['3.6', true],