Skip to content

Commit

Permalink
additional logs and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Aug 15, 2024
1 parent 146b2e9 commit bdfd2f8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
10 changes: 10 additions & 0 deletions __tests__/functions/exclude.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Exclude} from '../../src/functions/exclude'
const warningMock = jest.spyOn(core, 'warning').mockImplementation(() => {})
const setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation(() => {})
const infoMock = jest.spyOn(core, 'info').mockImplementation(() => {})
const debugMock = jest.spyOn(core, 'debug').mockImplementation(() => {})

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

test('does not raise an exception when no exclude file is found and it is required', () => {
process.env.INPUT_EXCLUDE_FILE = ''
process.env.INPUT_EXCLUDE_FILE_REQUIRED = 'true'

const exclude = new Exclude()
expect(exclude.isExcluded('exclude-me.json')).toBe(false)
expect(debugMock).toHaveBeenCalledWith(`exclude_file was not provided - OK`)
})

test('excludes a file that is not tracked by git', () => {
process.env.INPUT_EXCLUDE_FILE = ''
const exclude = new Exclude()
Expand Down
2 changes: 2 additions & 0 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as core from '@actions/core'
import {run} from '../src/main'
import * as jsonValidator from '../src/functions/json-validator'
import * as yamlValidator from '../src/functions/yaml-validator'
import * as processResults from '../src/functions/process-results'

beforeEach(() => {
jest.clearAllMocks()
jest.spyOn(core, 'debug').mockImplementation(() => {})
jest.spyOn(jsonValidator, 'jsonValidator').mockImplementation(() => {
return {success: true, failed: 0, passed: 8, skipped: 0, violations: []}
})
Expand Down
2 changes: 2 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/functions/exclude.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class Exclude {

core.info(`exclude_file was not found, but it is not required - OK`)
}
} else {
core.debug(`exclude_file was not provided - OK`)
}

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

0 comments on commit bdfd2f8

Please sign in to comment.