Skip to content

Commit 77bdada

Browse files
authored
chore: add tests (#11)
* chore: add tests BREAKING CHANGE: move to 1.0.0 with 100% code coverage * add travis config and coveralls
1 parent 0e9c61e commit 77bdada

File tree

10 files changed

+553
-7
lines changed

10 files changed

+553
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules/
2+
.nyc_output/

.travis.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- '4'
5+
- 'node'
6+
after_success: npm run coverage

cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rekcod(process.argv.slice(2), (err, runObjects) => {
88
if (err.stdout) console.log(err.stdout)
99
if (err.stderr) console.error(err.stderr)
1010
else console.error(err)
11-
return process.exit(err.code || 1)
11+
return process.exit((!isNaN(err.code) && err.code) || 1)
1212
}
1313

1414
runObjects.forEach((r) => {

index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
'use strict'
22

3-
const child_process = require("child_process")
3+
const childProcess = require('child_process')
44

55
module.exports = function (containers, cb) {
66
let cbCalled = false
7-
let stdout = [], stderr = []
8-
let child = child_process.spawn('docker', ['inspect'].concat(containers))
7+
let stdout = []
8+
let stderr = []
9+
let child = childProcess.spawn('docker', ['inspect'].concat(containers))
910
child.stderr.on('data', (data) => {
1011
stderr.push(data)
1112
})

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"scripts": {
1010
"pretest": "standard",
11-
"test": "nyc ava",
11+
"test": "nyc tape test/test*.js",
12+
"coverage": "nyc report --reporter=text-lcov | coveralls",
1213
"release": "standard-version"
1314
},
1415
"repository": {
@@ -27,6 +28,10 @@
2728
},
2829
"homepage": "https://github.com/nexdrew/rekcod#readme",
2930
"devDependencies": {
30-
"standard-version": "^2.1.2"
31+
"coveralls": "^2.11.14",
32+
"nyc": "^8.3.0",
33+
"standard": "^8.3.0",
34+
"standard-version": "^2.4.0",
35+
"tape": "^4.6.2"
3136
}
32-
}
37+
}

test/docker

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env node
2+
var containers = process.argv.splice(3)
3+
if (~containers.indexOf('error')) {
4+
console.log('Preparing to error out')
5+
console.error('An error has occurred')
6+
process.exit(127)
7+
}
8+
var dockerCommand = process.argv[2]
9+
var path = require('path')
10+
var file = path.join(__dirname, 'fixtures', dockerCommand + '-' + containers.join('-') + '.json')
11+
var fixture = require('fs').readFileSync(file, {
12+
encoding: 'utf8'
13+
})
14+
console.log(fixture)

test/fixtures/inspect-empty.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

test/fixtures/inspect-invalid.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
docker: "inspect" requires a minimum of 1 argument.
2+
See 'docker inspect --help'.
3+
4+
Usage: docker inspect [OPTIONS] CONTAINER|IMAGE|TASK [CONTAINER|IMAGE|TASK...]
5+
6+
Return low-level information on a container, image or task

0 commit comments

Comments
 (0)