Skip to content

Commit

Permalink
chore: Update Node.js version to 20 in action.yml and package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
vhsantos26 committed Jul 4, 2024
1 parent 1e5c3f9 commit b5fa3f8
Show file tree
Hide file tree
Showing 10 changed files with 3,312 additions and 2,643 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: ALJAZEERAPLUS/sauce-labs-storage-action@v2
with:
endpoint-action: upload
file-path: app/build/outputs/apk/release/app-release.apk
upload-file-path: app/build/outputs/apk/release/app-release.apk
sauce-labs-username: ${{ secrets.SAUCELABS_USERNAME }}
sauce-labs-access-key: ${{ secrets.SAUCELABS_ACCESS_KEY }}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const axios = require('axios');
const core = require('@actions/core');
const files = require('../../../src/endpoints/storage/files');
const fetchFiles = require('../../../src/endpoints/storage/fetchFiles');

jest.mock('axios');
jest.mock('@actions/core');
Expand All @@ -22,15 +22,16 @@ describe('Files Endpoint', () => {
});

test('sends correct authorization header', async () => {
await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalledWith(expect.anything(), {
expect(axios.get).toHaveBeenCalledWith('https://api.region.saucelabs.com/v1/storage/files', {
headers: {
Authorization: `Basic ${Buffer.from('username:access-key').toString('base64')}`,
},
params: {
kind: 'ios',
per_page: 100,
page: 1,
},
});
});
Expand All @@ -42,11 +43,12 @@ describe('Files Endpoint', () => {
items: [{
id: '1234',
kind: 'android',
page: 1,
}],
},
});

await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalled();
expect(core.setOutput).toHaveBeenCalledWith('file-id', '1234');
Expand All @@ -61,18 +63,18 @@ describe('Files Endpoint', () => {
},
});

await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalledWith('No file found');
expect(core.setFailed).toHaveBeenCalledWith('File not found');
});

test('handles unexpected response code', async () => {
axios.get.mockResolvedValue({
status: 404,
});

await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalledWith('Unexpected error: Unexpected response code: 404');
Expand All @@ -84,7 +86,7 @@ describe('Files Endpoint', () => {
data: {},
});

await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalledWith('Unexpected error: Unexpected response structure');
Expand All @@ -93,7 +95,7 @@ describe('Files Endpoint', () => {
test('handles exception', async () => {
axios.get.mockRejectedValue(new Error('Network error'));

await files();
await fetchFiles();

expect(axios.get).toHaveBeenCalled();
expect(core.setFailed).toHaveBeenCalledWith('Unexpected error: Network error');
Expand Down Expand Up @@ -143,7 +145,7 @@ describe('Files Endpoint', () => {
mockValues['get-file-id-app-version'] = version;
core.getInput.mockImplementation((name) => mockValues[name]);

await files();
await fetchFiles();

expect(core.setOutput).toHaveBeenCalledWith('file-id', expected);
});
Expand All @@ -157,7 +159,7 @@ describe('Files Endpoint', () => {
mockValues['get-file-id-app-build-number'] = build;
core.getInput.mockImplementation((name) => mockValues[name]);

await files();
await fetchFiles();

expect(core.setOutput).toHaveBeenCalledWith('file-id', expected);
});
Expand All @@ -170,7 +172,7 @@ describe('Files Endpoint', () => {
mockValues['get-file-id-app-description'] = description;
core.getInput.mockImplementation((name) => mockValues[name]);

await files();
await fetchFiles();

expect(core.setOutput).toHaveBeenCalledWith('file-id', expected);
});
Expand Down
8 changes: 4 additions & 4 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable global-require */
const core = require('@actions/core');
const upload = require('../src/endpoints/storage/upload');
const files = require('../src/endpoints/storage/files');
const fetchFiles = require('../src/endpoints/storage/fetchFiles');
const index = require('../src/index');

jest.mock('@actions/core', () => ({
Expand All @@ -10,7 +10,7 @@ jest.mock('@actions/core', () => ({
info: jest.fn(),
}));
jest.mock('../src/endpoints/storage/upload');
jest.mock('../src/endpoints/storage/files');
jest.mock('../src/endpoints/storage/fetchFiles');

describe('Action execution', () => {
afterEach(() => {
Expand All @@ -23,15 +23,15 @@ describe('Action execution', () => {
await index.main();

expect(upload).toHaveBeenCalled();
expect(files).not.toHaveBeenCalled();
expect(fetchFiles).not.toHaveBeenCalled();
});

it('should call files when endpoint-action is "get-file-id"', async () => {
core.getInput.mockReturnValue('get-file-id');

await index.main();

expect(files).toHaveBeenCalled();
expect(fetchFiles).toHaveBeenCalled();
expect(upload).not.toHaveBeenCalled();
});

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ branding:
icon: upload-cloud
color: red
runs:
using: node16
using: node20
main: dist/index.js
Loading

0 comments on commit b5fa3f8

Please sign in to comment.