Permalink
Cannot retrieve contributors at this time
50 lines (41 sloc)
1.43 KB
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
login-action/__tests__/docker.test.ts
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
// @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 = 'dbowie'; | |
const password = 'groundcontrol'; | |
const registry = 'https://ghcr.io'; | |
await loginStandard(registry, username, password); | |
expect(execSpy).toHaveBeenCalledWith(`docker`, ['login', '--password-stdin', '--username', username, registry], { | |
input: Buffer.from(password), | |
silent: true, | |
ignoreReturnCode: true | |
}); | |
}); | |
test('logout calls exec', async () => { | |
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | |
// @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 = 'https://ghcr.io'; | |
await logout(registry); | |
expect(execSpy).toHaveBeenCalledWith(`docker`, ['logout', registry], { | |
ignoreReturnCode: true | |
}); | |
}); |