mirror of
https://github.com/docker/login-action.git
synced 2025-05-12 00:19:29 +02:00
fix cases: kebab for action, camelCase for TS
Signed-off-by: Fedor Dikarev <fedor.dikarev@gmail.com>
This commit is contained in:
parent
c4d11d0a1e
commit
1e8f0ae375
5 changed files with 37 additions and 37 deletions
|
@ -6,15 +6,15 @@ import {login} from '../src/docker';
|
|||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||
|
||||
test('login retries function', async () => {
|
||||
let stderr_strings: string[] = [];
|
||||
let call_count: number = -1;
|
||||
let stderrStrings: string[] = [];
|
||||
let callCount: number = -1;
|
||||
|
||||
// using spyOn() here isn't enough, as we alter the logic
|
||||
// so use `jest.fn()` here for the `Docker.getExecOutput`
|
||||
Docker.getExecOutput = jest.fn(async () => {
|
||||
call_count++;
|
||||
console.log(`Mock: ${call_count}, ${stderr_strings}`);
|
||||
if (call_count >= stderr_strings.length) {
|
||||
callCount++;
|
||||
console.log(`Mock: ${callCount}, ${stderrStrings}`);
|
||||
if (callCount >= stderrStrings.length) {
|
||||
return {
|
||||
exitCode: 0,
|
||||
stdout: 'Mock success',
|
||||
|
@ -24,7 +24,7 @@ test('login retries function', async () => {
|
|||
return {
|
||||
exitCode: 1,
|
||||
stdout: '',
|
||||
stderr: stderr_strings[call_count % stderr_strings.length]
|
||||
stderr: stderrStrings[callCount % stderrStrings.length]
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -32,15 +32,15 @@ test('login retries function', async () => {
|
|||
const password = 'groundcontrol';
|
||||
const registry = 'https://ghcr.io';
|
||||
|
||||
stderr_strings = ['mock error, failed with status: 408 Request Timeout', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
call_count = -1;
|
||||
stderrStrings = ['mock error, failed with status: 408 Request Timeout', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
callCount = -1;
|
||||
await expect(async () => {
|
||||
await login(registry, username, password, 'false', ['408', '400'], 5, 0.1);
|
||||
}).rejects.toThrow('mock error, failed with status: 502 Request Timeout');
|
||||
expect(Docker.getExecOutput).toHaveBeenCalledTimes(2);
|
||||
|
||||
stderr_strings = ['not matching error', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
call_count = -1;
|
||||
stderrStrings = ['not matching error', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
callCount = -1;
|
||||
await expect(async () => {
|
||||
await login(registry, username, password, 'false', ['408', '400'], 5, 0.1);
|
||||
}).rejects.toThrow('not matching error');
|
||||
|
|
|
@ -4,15 +4,15 @@ import {login} from '../src/docker';
|
|||
import {Docker} from '@docker/actions-toolkit/lib/docker/docker';
|
||||
|
||||
test('login retries success function', async () => {
|
||||
let stderr_strings: string[] = [];
|
||||
let call_count: number = -1;
|
||||
let stderrStrings: string[] = [];
|
||||
let callCount: number = -1;
|
||||
|
||||
// using spyOn() here isn't enough, as we alter the logic
|
||||
// so use `jest.fn()` here for the `Docker.getExecOutput`
|
||||
Docker.getExecOutput = jest.fn(async () => {
|
||||
call_count++;
|
||||
console.log(`Mock: ${call_count}, ${stderr_strings}`);
|
||||
if (call_count >= stderr_strings.length) {
|
||||
callCount++;
|
||||
console.log(`Mock: ${callCount}, ${stderrStrings}`);
|
||||
if (callCount >= stderrStrings.length) {
|
||||
return {
|
||||
exitCode: 0,
|
||||
stdout: 'Mock success',
|
||||
|
@ -22,7 +22,7 @@ test('login retries success function', async () => {
|
|||
return {
|
||||
exitCode: 1,
|
||||
stdout: '',
|
||||
stderr: stderr_strings[call_count % stderr_strings.length]
|
||||
stderr: stderrStrings[callCount % stderrStrings.length]
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -30,13 +30,13 @@ test('login retries success function', async () => {
|
|||
const password = 'groundcontrol';
|
||||
const registry = 'https://ghcr.io';
|
||||
|
||||
stderr_strings = [];
|
||||
call_count = -1;
|
||||
stderrStrings = [];
|
||||
callCount = -1;
|
||||
await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1);
|
||||
expect(Docker.getExecOutput).toHaveBeenCalledTimes(1);
|
||||
|
||||
stderr_strings = ['mock error, failed with status: 408 Request Timeout', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
call_count = -1;
|
||||
stderrStrings = ['mock error, failed with status: 408 Request Timeout', 'mock error, failed with status: 502 Request Timeout', 'mock error, failed with status: 400 Request Timeout'];
|
||||
callCount = -1;
|
||||
await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1);
|
||||
expect(Docker.getExecOutput).toHaveBeenCalledTimes(1 + 4);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue