Skip to content

Commit

Permalink
Merge pull request #158 from crazy-max/node-16
Browse files Browse the repository at this point in the history
update to node 16
  • Loading branch information
crazy-max authored Feb 28, 2022
2 parents 6af3c11 + 4b59a42 commit 4e3c937
Show file tree
Hide file tree
Showing 17 changed files with 6,184 additions and 59,683 deletions.
1 change: 1 addition & 0 deletions __tests__/aws.test.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ inputs:
required: false

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

0 comments on commit 4e3c937

Please sign in to comment.