Skip to content

Commit

Permalink
Fixes tests (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
zgosalvez authored Dec 17, 2023
1 parent 4254f3d commit ba37328
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
26 changes: 12 additions & 14 deletions test/fail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,28 @@ jest.afterEach(() => {

jest.test('action has empty error', () => {
process.env[workflowsPath] = 'test/stub/empty';
let result;

try {
cp.execSync(`node ${ip}`, { env: process.env }).toString();

jest.expect(true).toBe(false);
throw cp.execSync(`node ${ip}`, { env: process.env }).toString();
} catch (error) {
const result = error.stdout.toString();

jest.expect(result).toContain('Cannot read properties of null (reading \'jobs\')');
jest.expect(result).not.toContain('No issues were found.');
result = (error.stdout || error).toString();
}

jest.expect(result).toContain('Cannot read properties of null (reading \'jobs\')');
jest.expect(result).not.toContain('No issues were found.');
});

jest.test('action has unpinned error', () => {
process.env[workflowsPath] = 'test/stub/unpinned';
let result;

try {
cp.execSync(`node ${ip}`, { env: process.env }).toString();

jest.expect(true).toBe(false);
throw cp.execSync(`node ${ip}`, { env: process.env }).toString();
} catch (error) {
const result = error.stdout.toString();

jest.expect(result).toContain('actions/checkout@v1 is not pinned to a full length commit SHA.');
jest.expect(result).not.toContain('No issues were found.');
result = (error.stdout || error).toString();
}

jest.expect(result).toContain('actions/checkout@v1 is not pinned to a full length commit SHA.');
jest.expect(result).not.toContain('No issues were found.');
});
4 changes: 2 additions & 2 deletions test/pass.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jest.test('actions pass', () => {
let result;

try {
result = execSync(`node ${ip}`, { env: process.env }).toString();
throw execSync(`node ${ip}`, { env: process.env }).toString();
} catch (error) {
throw Error(error.stdout.toString());
result = (error.stdout || error).toString();
}

jest.expect(result).not.toContain('::warning::');
Expand Down
5 changes: 0 additions & 5 deletions test/stub/unpinned/file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@ jobs:
steps:
- uses: docker://rhysd/actionlint:latest
- uses: docker://rhysd/actionlint:1.6.22
mixedstub:
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

5 changes: 5 additions & 0 deletions test/stub/unpinned/file2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
jobs:
mixedstub:
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f

0 comments on commit ba37328

Please sign in to comment.