Signed-off-by: Fedor Dikarev <fedor.dikarev@gmail.com>
This commit is contained in:
Fedor Dikarev 2025-01-23 15:44:53 +01:00
parent 5e10840d3c
commit 6cade5565f

View file

@ -4,12 +4,7 @@ import { login } from '../src/docker';
import { Docker } from '@docker/actions-toolkit/lib/docker/docker'; import { Docker } from '@docker/actions-toolkit/lib/docker/docker';
test('login retries success function', async () => { test('login retries success function', async () => {
// let stderr_strings: string[] = [] let stderr_strings: string[] = []
let stderr_strings: string[] = [
'mock error, failed with status: 408 Request Timeout',
'mock error, failed with status: 502 Request Timeout',
'mock error, failed with status: 400 Request Timeout',
]
let call_count: number = -1 let call_count: number = -1
Docker.getExecOutput = jest.fn(async () => { Docker.getExecOutput = jest.fn(async () => {
@ -33,12 +28,9 @@ test('login retries success function', async () => {
const password = 'groundcontrol'; const password = 'groundcontrol';
const registry = 'https://ghcr.io'; const registry = 'https://ghcr.io';
// stderr_strings = [] stderr_strings = []
call_count = -1 call_count = -1
await expect(async () => { await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1);
await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1);
})
.resolves;
expect(Docker.getExecOutput).toHaveBeenCalledTimes(1); expect(Docker.getExecOutput).toHaveBeenCalledTimes(1);
stderr_strings = [ stderr_strings = [
@ -47,9 +39,6 @@ test('login retries success function', async () => {
'mock error, failed with status: 400 Request Timeout', 'mock error, failed with status: 400 Request Timeout',
] ]
call_count = -1 call_count = -1
await expect(async () => { await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1);
await login(registry, username, password, 'false', ['408', '502', '400'], 5, 0.1); expect(Docker.getExecOutput).toHaveBeenCalledTimes(1 + 4);
})
.resolves;
expect(Docker.getExecOutput).toHaveBeenCalledTimes(0);
}); });