Skip to content

Commit bdfd2f8

Browse files
committed
additional logs and tests
1 parent 146b2e9 commit bdfd2f8

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

__tests__/functions/exclude.test.js

+10
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Exclude} from '../../src/functions/exclude'
44
const warningMock = jest.spyOn(core, 'warning').mockImplementation(() => {})
55
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation(() => {})
66
const infoMock = jest.spyOn(core, 'info').mockImplementation(() => {})
7+
const debugMock = jest.spyOn(core, 'debug').mockImplementation(() => {})
78

89
var exclude
910
beforeEach(() => {
@@ -74,6 +75,15 @@ test('does not raise an exception when no exclude file is found and it is not re
7475
)
7576
})
7677

78+
test('does not raise an exception when no exclude file is found and it is required', () => {
79+
process.env.INPUT_EXCLUDE_FILE = ''
80+
process.env.INPUT_EXCLUDE_FILE_REQUIRED = 'true'
81+
82+
const exclude = new Exclude()
83+
expect(exclude.isExcluded('exclude-me.json')).toBe(false)
84+
expect(debugMock).toHaveBeenCalledWith(`exclude_file was not provided - OK`)
85+
})
86+
7787
test('excludes a file that is not tracked by git', () => {
7888
process.env.INPUT_EXCLUDE_FILE = ''
7989
const exclude = new Exclude()

__tests__/main.test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import * as core from '@actions/core'
12
import {run} from '../src/main'
23
import * as jsonValidator from '../src/functions/json-validator'
34
import * as yamlValidator from '../src/functions/yaml-validator'
45
import * as processResults from '../src/functions/process-results'
56

67
beforeEach(() => {
78
jest.clearAllMocks()
9+
jest.spyOn(core, 'debug').mockImplementation(() => {})
810
jest.spyOn(jsonValidator, 'jsonValidator').mockImplementation(() => {
911
return {success: true, failed: 0, passed: 8, skipped: 0, violations: []}
1012
})

dist/index.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/functions/exclude.js

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export class Exclude {
2525

2626
core.info(`exclude_file was not found, but it is not required - OK`)
2727
}
28+
} else {
29+
core.debug(`exclude_file was not provided - OK`)
2830
}
2931

3032
// if gitTrackOnly is true, add the git exclude patterns from the .gitignore file if it exists

0 commit comments

Comments
 (0)