Skip to content

Commit

Permalink
Fix e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed May 10, 2022
1 parent e5523d6 commit 2358e7c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/versions.yml
Expand Up @@ -42,6 +42,9 @@ jobs:
uses: ./
with:
node-version: ${{ matrix.node-version }}
- name: Verify node and npm
run: __tests__/verify-node.sh "$(nvm version "${{ matrix.node-version }}")"
shell: bash

manifest:
runs-on: ${{ matrix.os }}
Expand Down
16 changes: 8 additions & 8 deletions __tests__/installer.test.ts
Expand Up @@ -839,9 +839,9 @@ describe('setup-node', () => {
);
});

it('find latest LTS version and resolve it from local cache (lts/-2)', async () => {
it('find latest LTS version and resolve it from local cache (lts/-1)', async () => {
// arrange
inputs['node-version'] = 'lts/-2';
inputs['node-version'] = 'lts/-1';

const toolPath = path.normalize('/cache/node/12.16.2/x64');
findSpy.mockReturnValue(toolPath);
Expand All @@ -858,20 +858,20 @@ describe('setup-node', () => {
);
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
expect(dbgSpy).toHaveBeenCalledWith(
`LTS alias '-2' for Node version 'lts/-2'`
`LTS alias '-1' for Node version 'lts/-1'`
);
expect(dbgSpy).toHaveBeenCalledWith(
`Found LTS release '12.16.2' for Node version 'lts/-2'`
`Found LTS release '12.16.2' for Node version 'lts/-1'`
);
expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`);
expect(cnSpy).toHaveBeenCalledWith(
`::add-path::${path.join(toolPath, 'bin')}${osm.EOL}`
);
});

it('find latest LTS version and install it from manifest (lts/-2)', async () => {
it('find latest LTS version and install it from manifest (lts/-1)', async () => {
// arrange
inputs['node-version'] = 'lts/-2';
inputs['node-version'] = 'lts/-1';

const toolPath = path.normalize('/cache/node/12.16.2/x64');
findSpy.mockImplementation(() => '');
Expand All @@ -893,10 +893,10 @@ describe('setup-node', () => {
);
expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached');
expect(dbgSpy).toHaveBeenCalledWith(
`LTS alias '-2' for Node version 'lts/-2'`
`LTS alias '-1' for Node version 'lts/-1'`
);
expect(dbgSpy).toHaveBeenCalledWith(
`Found LTS release '12.16.2' for Node version 'lts/-2'`
`Found LTS release '12.16.2' for Node version 'lts/-1'`
);
expect(logSpy).toHaveBeenCalledWith('Attempting to download 12...');
expect(logSpy).toHaveBeenCalledWith(
Expand Down
4 changes: 2 additions & 2 deletions dist/setup/index.js
Expand Up @@ -62479,8 +62479,8 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
// Supported formats are `lts/<alias>`, `lts/*`, and `lts/-n`. Where asterisk means highest possible LTS and -n means the nth-highest.
const n = Number(alias);
const aliases = Object.fromEntries(manifest
.filter(x => x.stable === stable)
.map(x => { var _a; return [(_a = x.lts) === null || _a === void 0 ? void 0 : _a.toLowerCase(), x]; }));
.filter(x => x.stable === stable && x.lts)
.map(x => [x.lts.toLowerCase(), x]));
const numbered = Object.values(aliases);
const release = alias === '*'
? numbered[numbered.length - 1]
Expand Down
4 changes: 2 additions & 2 deletions src/installer.ts
Expand Up @@ -222,8 +222,8 @@ function resolveLtsAliasFromManifest(
const n = Number(alias);
const aliases = Object.fromEntries(
manifest
.filter(x => x.stable === stable)
.map(x => [x.lts?.toLowerCase(), x])
.filter(x => x.stable === stable && x.lts)
.map(x => [x.lts!.toLowerCase(), x])
);
const numbered = Object.values(aliases);
const release =
Expand Down

0 comments on commit 2358e7c

Please sign in to comment.