1
0
Fork 0
mirror of https://github.com/docker/login-action.git synced 2025-04-22 14:46:37 +02:00

Use core.getBooleanInput

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2021-06-22 10:39:55 +02:00
parent e2346b6971
commit 4fd5d8ead6
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
6 changed files with 34 additions and 7 deletions

View file

@ -5,6 +5,7 @@ import {getInputs} from '../src/context';
test('with password and username getInputs does not throw error', async () => {
process.env['INPUT_USERNAME'] = 'dbowie';
process.env['INPUT_PASSWORD'] = 'groundcontrol';
process.env['INPUT_LOGOUT'] = 'true';
expect(() => {
getInputs();
}).not.toThrowError();

View file

@ -10,6 +10,8 @@ test('errors without username and password', async () => {
const platSpy = jest.spyOn(osm, 'platform');
platSpy.mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy: jest.SpyInstance = jest.spyOn(core, 'setFailed');
await run();
@ -32,10 +34,13 @@ test('successful with username and password', async () => {
const password: string = 'groundcontrol';
process.env[`INPUT_PASSWORD`] = password;
const logout: boolean = false;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
expect(setRegistrySpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
expect(dockerSpy).toHaveBeenCalledWith('', username, password);
});
@ -57,8 +62,8 @@ test('calls docker login', async () => {
const registry: string = 'ghcr.io';
process.env[`INPUT_REGISTRY`] = registry;
const logout: string = 'true';
process.env['INPUT_LOGOUT'] = logout;
const logout: boolean = true;
process.env['INPUT_LOGOUT'] = String(logout);
await run();