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

switch to actions-toolkit implementation

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2023-02-21 10:06:17 +01:00
parent 3da7dc6e2b
commit af023e8f62
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
10 changed files with 272 additions and 88 deletions

View file

@ -1,19 +1,14 @@
import {expect, jest, test} from '@jest/globals';
import osm = require('os');
import {run} from '../src/main';
import {main} from '../src/main';
import * as docker from '../src/docker';
import * as stateHelper from '../src/state-helper';
import * as core from '@actions/core';
test('errors without username and password', async () => {
jest.spyOn(osm, 'platform').mockImplementation(() => 'linux');
process.env['INPUT_LOGOUT'] = 'true'; // default value
const coreSpy = jest.spyOn(core, 'setFailed');
await run();
expect(coreSpy).toHaveBeenCalledWith('Username and password required');
await expect(main()).rejects.toThrowError(new Error('Username and password required'));
});
test('successful with username and password', async () => {
@ -34,7 +29,7 @@ test('successful with username and password', async () => {
const logout = false;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
await main();
expect(setRegistrySpy).toHaveBeenCalledWith('');
expect(setLogoutSpy).toHaveBeenCalledWith(logout);
@ -63,7 +58,7 @@ test('calls docker login', async () => {
const logout = true;
process.env['INPUT_LOGOUT'] = String(logout);
await run();
await main();
expect(setRegistrySpy).toHaveBeenCalledWith(registry);
expect(setLogoutSpy).toHaveBeenCalledWith(logout);