Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file validation in action summary #76

Merged
merged 3 commits into from
Aug 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
update tests
  • Loading branch information
GrantBirki committed Aug 24, 2024
commit 9c3b7add182efe0b2f1433372da41b33a115062c
19 changes: 19 additions & 0 deletions __tests__/functions/json-validator.test.js
Original file line number Diff line number Diff line change
@@ -462,6 +462,25 @@ test('successfully validates json files with a schema when files is defined', as
expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
})

test('successfully validates json files with a schema when files is defined and there are duplicates', async () => {
const files = [
'__tests__/fixtures/json/valid/json1.json',
'__tests__/fixtures/json/valid/json1.json',
'__tests__/fixtures/json/project_dir/data/config/json1.json'
]
process.env.INPUT_FILES = files.join('\n')

expect(await jsonValidator(excludeMock)).toStrictEqual({
failed: 0,
passed: 2,
skipped: 0,
success: true,
violations: []
})

expect(debugMock).toHaveBeenCalledWith(`using files: ${files.join(', ')}`)
})

test('fails to validate a yaml file with an incorrect schema when yaml_as_json is true', async () => {
process.env.INPUT_YAML_AS_JSON = 'true'
process.env.INPUT_BASE_DIR = '__tests__/fixtures/yaml_as_json/invalid'
5 changes: 3 additions & 2 deletions __tests__/functions/yaml-validator.test.js
Original file line number Diff line number Diff line change
@@ -128,7 +128,8 @@ test('fails to validate a yaml file without using a schema', async () => {
)
})

test('successfully validates yaml files with a schema when files is defined', async () => {
test('successfully validates yaml files with a schema when files is defined and there are duplicates', async () => {
// this file should only be validated once and not duplicated
const files = [
'__tests__/fixtures/yaml/valid/yaml1.yaml',
'__tests__/fixtures/yaml/valid/yaml1.yaml'
@@ -137,7 +138,7 @@ test('successfully validates yaml files with a schema when files is defined', as

expect(await yamlValidator(excludeMock)).toStrictEqual({
failed: 0,
passed: 2,
passed: 1,
skipped: 0,
success: true,
violations: []