Skip to content

Commit

Permalink
Merge pull request #184 from newrelic-forks/master
Browse files Browse the repository at this point in the history
tests: add command-exists tests
  • Loading branch information
prototypicalpro authored Oct 6, 2020
2 parents 0da11b9 + d2a762a commit ae6688c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ tmp/
.idea/
vendor/
.bundle
out
out
.vscode/
32 changes: 0 additions & 32 deletions .vscode/launch.json

This file was deleted.

1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ async function runRuleset (ruleset, targets, fileSystem, dryRun) {
const allRules = await loadRules()
// load the fixes
const allFixes = await loadFixes()
// do the same with fixes
// run the ruleset
const results = ruleset.map(async r => {
// check axioms and enable appropriately
Expand Down
35 changes: 35 additions & 0 deletions tests/lib/command_exists_tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2017 TODO Group. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

const chai = require('chai')
const expect = chai.expect
const { commandExists } = require('../../lib/command_exists')

describe('lib', () => {
describe('command_exists', function () {
it('should detect a command exists', async () => {
const res = await commandExists('ssh')
expect(res).to.equal('ssh')
})

it('should detect a command doesn\'t exists', async () => {
const res = await commandExists('notacommand')
expect(res).to.equal(null)
})

it('should detect one of the commands exist', async () => {
const res = await commandExists(['notacommand', 'ssh'])
expect(res).to.equal('ssh')
})

it('should detect none of the commands exist', async () => {
const res = await commandExists(['notacommand', 'alsonotacommand'])
expect(res).to.equal(null)
})

it('should detect the first command exists', async () => {
const res = await commandExists(['ssh', 'ln'])
expect(res).to.equal('ssh')
})
})
})

0 comments on commit ae6688c

Please sign in to comment.