Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to node 16 #158

Merged
merged 1 commit into from Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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'