Skip to content

Commit 410258f

Browse files
committed
Added test, removed too strong permissions
1 parent 6abd778 commit 410258f

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.checkov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
skip-check:
22
- CKV_GHA_1 # write-all permissions used
3+

__tests__/main.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,43 @@
88
// eslint-disable-next-line jest/no-commented-out-tests
99
import { jest } from '@jest/globals'
1010
import * as core from '../__fixtures__/core.js'
11+
//import { InputOptions } from "@actions/core";
1112

1213
// Mocks should be declared before the module being tested is imported.
1314
jest.unstable_mockModule('@actions/core', () => core)
1415

1516
// The module being tested should be imported dynamically. This ensures that the
16-
// mocks are used in place of any actual dependencies.
17-
//const { run } = await import('../src/main.js')
17+
//mocks are used in place of any actual dependencies.
18+
const { run } = await import('../src/main.js')
1819

1920
describe('main.ts', () => {
20-
/*beforeEach(() => {
21+
beforeEach(() => {
2122
// Set the action's inputs as return values from core.getInput().
22-
core.getInput.mockImplementation(() => '500')
23+
core.getInput.mockImplementation((name: string) => {
24+
if (name === 'schemaPath') return 'schema.json'
25+
else if (name === 'validate') return 'true'
26+
else return 'true'
27+
})
2328

2429
// Mock the wait function so that it does not actually wait.
25-
wait.mockImplementation(() => Promise.resolve('done!'))
30+
//wait.mockImplementation(() => Promise.resolve('done!'))
2631
})
32+
2733
afterEach(() => {
2834
jest.resetAllMocks()
2935
})
30-
it('Sets the time output', async () => {
36+
it('Sets the schema path', async () => {
3137
await run()
3238

3339
// Verify the time output was set.
3440
expect(core.setOutput).toHaveBeenNthCalledWith(
3541
1,
36-
'time',
42+
'message',
3743
// Simple regex to match a time string in the format HH:MM:SS.
38-
expect.stringMatching(/^\d{2}:\d{2}:\d{2}/)
44+
expect.stringMatching(/^JSON Schema Check Results/)
3945
)
4046
})
47+
/*
4148
it('Sets a failed status', async () => {
4249
// Clear the getInput mock and return an invalid value.
4350
core.getInput.mockClear().mockReturnValueOnce('this is not a number')

0 commit comments

Comments
 (0)