Skip to content

Commit

Permalink
format, lint and build
Browse files Browse the repository at this point in the history
  • Loading branch information
timfel committed Jun 30, 2023
1 parent 1cbe27a commit 7f6a25b
Show file tree
Hide file tree
Showing 6 changed files with 387 additions and 92 deletions.
24 changes: 12 additions & 12 deletions __tests__/find-graalpy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import * as path from 'path';
import * as semver from 'semver';

import * as finder from '../src/find-graalpy';
import {
IGraalPyManifestRelease,
} from '../src/utils';
import {IGraalPyManifestRelease} from '../src/utils';

import manifestData from './data/graalpy.json';

let architecture = 'x64';
const architecture = 'x64';

const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
Expand All @@ -25,7 +23,7 @@ describe('parseGraalPyVersion', () => {
it.each([
['graalpy-23', '23'],
['graalpy-23.0', '23.0'],
['graalpy23.0', '23.0'],
['graalpy23.0', '23.0']
])('%s -> %s', (input, expected) => {
expect(finder.parseGraalPyVersion(input)).toEqual(expected);
});
Expand Down Expand Up @@ -308,9 +306,7 @@ describe('findGraalPyVersion', () => {
)
).resolves.toEqual('23.0.0');

expect(infoSpy).toHaveBeenCalledWith(
'Resolved as GraalPy 23.0.0'
);
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});

it('check-latest enabled version found and install successfully', async () => {
Expand All @@ -329,9 +325,7 @@ describe('findGraalPyVersion', () => {
false
)
).resolves.toEqual('23.0.0');
expect(infoSpy).toHaveBeenCalledWith(
'Resolved as GraalPy 23.0.0'
);
expect(infoSpy).toHaveBeenCalledWith('Resolved as GraalPy 23.0.0');
});

it('check-latest enabled version is not found and used from toolcache', async () => {
Expand Down Expand Up @@ -366,7 +360,13 @@ describe('findGraalPyVersion', () => {
spyChmodSync = jest.spyOn(fs, 'chmodSync');
spyChmodSync.mockImplementation(() => undefined);
await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, false)
finder.findGraalPyVersion(
'graalpy23.1',
architecture,
false,
false,
false
)
).rejects.toThrow();
await expect(
finder.findGraalPyVersion('graalpy23.1', architecture, false, false, true)
Expand Down
50 changes: 11 additions & 39 deletions __tests__/install-graalpy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import manifestData from './data/graalpy.json';

let architecture: string = 'x64';
const architecture = 'x64';

const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');
Expand All @@ -36,7 +36,7 @@ describe('findRelease', () => {
const result = JSON.stringify(manifestData);
const releases = JSON.parse(result) as IGraalPyManifestRelease[];
const extension = 'tar.gz';
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
const arch = architecture === 'x64' ? 'amd64' : 'aarch64';
const extensionName = IS_WINDOWS
? `windows-${arch}.${extension}`
: `${process.platform}-${arch}.${extension}`;
Expand Down Expand Up @@ -67,24 +67,14 @@ describe('findRelease', () => {
it("GraalPy version doesn't match", () => {
const graalpyVersion = '12.0.0';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toEqual(null);
});

it('GraalPy version matches', () => {
const graalpyVersion = '23.0.0';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: graalpyVersion
Expand All @@ -94,12 +84,7 @@ describe('findRelease', () => {
it('Preview version of GraalPy is found', () => {
const graalpyVersion = installer.graalPyTagToVersion('vm-23.1.0a1');
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: {
name: `graalpython-23.1.0a1-${extensionName}`,
Expand All @@ -112,12 +97,7 @@ describe('findRelease', () => {
it('Latest GraalPy is found', () => {
const graalpyVersion = 'x';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toMatchObject({
foundAsset: files,
resolvedGraalPyVersion: '23.0.0'
Expand All @@ -127,20 +107,10 @@ describe('findRelease', () => {
it('GraalPy version matches semver (pre-release)', () => {
const graalpyVersion = '23.1.x';
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
false
)
installer.findRelease(releases, graalpyVersion, architecture, false)
).toBeNull();
expect(
installer.findRelease(
releases,
graalpyVersion,
architecture,
true
)
installer.findRelease(releases, graalpyVersion, architecture, true)
).toMatchObject({
foundAsset: filesRC1,
resolvedGraalPyVersion: '23.1.0-a.1'
Expand All @@ -167,7 +137,9 @@ describe('installGraalPy', () => {

beforeEach(() => {
tcFind = jest.spyOn(tc, 'find');
tcFind.mockImplementation(() => path.join('GraalPy', '3.6.12', architecture));
tcFind.mockImplementation(() =>
path.join('GraalPy', '3.6.12', architecture)
);

spyDownloadTool = jest.spyOn(tc, 'downloadTool');
spyDownloadTool.mockImplementation(() => path.join(tempDir, 'GraalPy'));
Expand Down

0 comments on commit 7f6a25b

Please sign in to comment.