Skip to content

Commit

Permalink
update to node 16
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max committed Feb 28, 2022
1 parent 6af3c11 commit 832a805
Show file tree
Hide file tree
Showing 17 changed files with 8,752 additions and 58,275 deletions.
1 change: 1 addition & 0 deletions __tests__/aws.test.ts
@@ -1,3 +1,4 @@
import {beforeEach, describe, expect, jest, test} from '@jest/globals';
import {AuthorizationData} from '@aws-sdk/client-ecr';
import * as aws from '../src/aws';

Expand Down
1 change: 1 addition & 0 deletions __tests__/context.test.ts
@@ -1,3 +1,4 @@
import {expect, test} from '@jest/globals';
import {getInputs} from '../src/context';

test('with password and username getInputs does not throw error', async () => {
Expand Down
23 changes: 11 additions & 12 deletions __tests__/docker.test.ts
@@ -1,20 +1,19 @@
import {expect, jest, test} from '@jest/globals';
import {loginStandard, logout} from '../src/docker';

import * as path from 'path';

import * as exec from '@actions/exec';

process.env['RUNNER_TEMP'] = path.join(__dirname, 'runner');

test('loginStandard calls exec', async () => {
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
execSpy.mockImplementation(() =>
Promise.resolve({
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
stderr: expect.any(Function)
})
);
};
});

const username: string = 'dbowie';
const password: string = 'groundcontrol';
Expand All @@ -30,14 +29,14 @@ test('loginStandard calls exec', async () => {
});

test('logout calls exec', async () => {
const execSpy: jest.SpyInstance = jest.spyOn(exec, 'getExecOutput');
execSpy.mockImplementation(() =>
Promise.resolve({
// @ts-ignore
const execSpy = jest.spyOn(exec, 'getExecOutput').mockImplementation(async () => {
return {
exitCode: expect.any(Number),
stdout: expect.any(Function),
stderr: expect.any(Function)
})
);
};
});

const registry: string = 'https://ghcr.io';

Expand Down
31 changes: 12 additions & 19 deletions __tests__/main.test.ts
@@ -1,3 +1,4 @@
import {expect, jest, test} from '@jest/globals';
import osm = require('os');

import {run} from '../src/main';
Expand All @@ -7,26 +8,20 @@ import * as stateHelper from '../src/state-helper';
import * as core from '@actions/core';

test('errors without username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');

process.env['INPUT_LOGOUT'] = 'true'; // default value

const coreSpy: jest.SpyInstance = jest.spyOn(core, 'setFailed');
const coreSpy = jest.spyOn(core, 'setFailed');

await run();

expect(coreSpy).toHaveBeenCalledWith('Username and password required');
});

test('successful with username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');

const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login').mockImplementation(jest.fn());

const username: string = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
Expand All @@ -48,13 +43,11 @@ test('successful with username and password', async () => {
});

test('calls docker login', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');

const setRegistrySpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy: jest.SpyInstance = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy: jest.SpyInstance = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(() => {});
const platSpy = jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
const setRegistrySpy = jest.spyOn(stateHelper, 'setRegistry');
const setLogoutSpy = jest.spyOn(stateHelper, 'setLogout');
const dockerSpy = jest.spyOn(docker, 'login');
dockerSpy.mockImplementation(jest.fn());

const username: string = 'dbowie';
process.env[`INPUT_USERNAME`] = username;
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Expand Up @@ -26,6 +26,6 @@ inputs:
required: false

runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
post: 'dist/index.js'

0 comments on commit 832a805

Please sign in to comment.