generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
34 lines (26 loc) · 1.25 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const core = require('@actions/core');
const {mockClient} = require('aws-sdk-client-mock');
const {CodeartifactClient, GetRepositoryEndpointCommand, GetAuthorizationTokenCommand} = require('@aws-sdk/client-codeartifact');
const {run} = require('./index');
jest.mock('@actions/core');
const codeArtifactMock = mockClient(CodeartifactClient);
const CODEARTIFACT_ENDPOINT_PYPI = 'https://endpoint.codeartifact.pypi';
const CODEARTIFACT_AUTH_TOKEN = 'asdfgqwert';
describe('configure-aws-codeartifact', () => {
beforeEach(() => {
codeArtifactMock.reset();
});
test('exports env vars', async () => {
codeArtifactMock.on(GetRepositoryEndpointCommand).resolvesOnce({
repositoryEndpoint: CODEARTIFACT_ENDPOINT_PYPI
});
codeArtifactMock.on(GetAuthorizationTokenCommand).resolvesOnce({
authorizationToken: CODEARTIFACT_AUTH_TOKEN
});
await run();
expect(core.exportVariable).toHaveBeenCalledWith('CODEARTIFACT_ENDPOINT_PYPI', CODEARTIFACT_ENDPOINT_PYPI);
expect(core.setOutput).toHaveBeenCalledWith('endpoint-pypi', CODEARTIFACT_ENDPOINT_PYPI);
expect(core.exportVariable).toHaveBeenCalledWith('CODEARTIFACT_AUTH_TOKEN', CODEARTIFACT_AUTH_TOKEN);
expect(core.setSecret).toHaveBeenCalledWith(CODEARTIFACT_AUTH_TOKEN);
});
});