Skip to content

Commit

Permalink
fix(validate-greenkeeper-json): groups key no longer required
Browse files Browse the repository at this point in the history
  • Loading branch information
espy authored and hulkoba committed Mar 26, 2018
1 parent 44431c2 commit c6970bc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/validate-greenkeeper-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const schema = Joi.object().keys({
packages: Joi.array().items(packagePathSchema).required(),
ignore: Joi.array()
}).optionalKeys(['ignore'])
).required(),
),
ignore: Joi.array()
}).optionalKeys(['ignore'])

Expand Down
17 changes: 14 additions & 3 deletions test/lib/validate-greenkeeper-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ test('valid with subgroup level ignore', () => {
expect(result.error).toBeFalsy()
})

test('valid without groups', () => {
const file = {
ignore: [
'totally-terrible-dependency'
]
}
const result = validate(file)
expect(result.error).toBeFalsy()
})

test('invalid: groupname has invalid characters', () => {
const file = {
groups: {
Expand Down Expand Up @@ -104,7 +114,7 @@ test('invalid: path is not ending on `package.json`', () => {
expect(result.error.details[0].message).toMatch(/fails to match the required pattern/)
})

test('invalid: no group/s', () => {
test('invalid: group/s not under group key', () => {
const file = {
frontend: {
packages: [
Expand All @@ -121,8 +131,9 @@ test('invalid: no group/s', () => {
const result = validate(file)
expect(result.error).toBeTruthy()
expect(result.error.name).toEqual('ValidationError')
expect(result.error.details.length).toEqual(1)
expect(result.error.details[0].message).toMatch(/"groups" is required/)
expect(result.error.details.length).toEqual(2)
expect(result.error.details[0].message).toMatch(/"frontend" is not allowed/)
expect(result.error.details[1].message).toMatch(/"backend" is not allowed/)
})

test('invalid: no packages', () => {
Expand Down

0 comments on commit c6970bc

Please sign in to comment.