Skip to content

Commit

Permalink
add test for detecting loops in extended rulesets
Browse files Browse the repository at this point in the history
  • Loading branch information
willnorris committed Apr 8, 2021
1 parent 43b95b6 commit 86af90f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/lib/config_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ describe('lib', () => {
expect(actual.rules['test-file-exists'].level).to.equals('off')
})

it('should detect loops in extended rulesets', async () => {
const loopSelf = await Config.loadConfig(
path.join(__dirname, 'loop-self.yaml')
)
expect(loopSelf.rules).to.have.property('test-file-exists')
expect(loopSelf.rules['test-file-exists'].level).to.equals('error')

const loopB = await Config.loadConfig(
path.join(__dirname, 'loop-b.yaml')
)
expect(loopB.rules).to.have.property('test-file-exists')
expect(loopB.rules['test-file-exists'].level).to.equals('off')
})

it('should throw error on non existant file', async () => {
expect(Config.loadConfig('/does-not-exist')).to.eventually.throw(
'ENOENT'
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/loop-a.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: "../../rulesets/schema.json"
extends: "./loop-b.yaml"
version: 2
rules:
test-file-exists:
level: error
6 changes: 6 additions & 0 deletions tests/lib/loop-b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: "../../rulesets/schema.json"
extends: "./loop-a.yaml"
version: 2
rules:
test-file-exists:
level: off
6 changes: 6 additions & 0 deletions tests/lib/loop-self.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: "../../rulesets/schema.json"
extends: "./loop-self.yaml"
version: 2
rules:
test-file-exists:
level: error

0 comments on commit 86af90f

Please sign in to comment.