Skip to content

Commit

Permalink
feat: clean up and cosolidate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Nov 13, 2017
1 parent b003584 commit 4d814b1
Show file tree
Hide file tree
Showing 6 changed files with 503 additions and 485 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"lint": "aegir lint",
"coverage": "aegir coverage",
"test": "aegir test --target node",
"test": "aegir test -t node --timeout 50000",
"docs": "aegir docs",
"release": "aegir release -t node",
"release-minor": "aegir release --type minor -t node",
Expand Down Expand Up @@ -58,7 +58,8 @@
"once": "^1.4.0",
"rimraf": "^2.6.2",
"shutdown": "^0.3.0",
"subcomandante": "^1.0.5"
"subcomandante": "^1.0.5",
"truthy": "0.0.1"
},
"devDependencies": {
"aegir": "^12.1.3",
Expand Down
4 changes: 3 additions & 1 deletion src/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const path = require('path')
const join = path.join
const once = require('once')
const os = require('os')
const truthy = require('truthy')

const isWindows = os.platform() === 'win32'

const exec = require('./exec')
Expand Down Expand Up @@ -91,7 +93,7 @@ class Node {
*/
constructor (path, opts, disposable) {
const rootPath = process.env.testpath ? process.env.testpath : __dirname
const isJS = process.env.IPFS_JS && process.env.IPFS_JS === 'true' // TODO: handle proper truthy/falsy
const isJS = truthy(process.env.IPFS_JS)

this.opts = opts || { isJs: isJS || false }
process.env.IPFS_JS = this.opts.isJs
Expand Down
14 changes: 14 additions & 0 deletions test/daemon.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-env mocha */
'use strict'

const daemon = require('./spawning-daemons.js')

describe('ipfsd-ctl', () => {
describe('Go daemon', () => {
daemon(false)()
})

describe('Js daemon', () => {
daemon(true)()
})
})
11 changes: 5 additions & 6 deletions test/npm-installs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ describe('ipfs executable path', () => {
const tmp = os.tmpdir()
const appName = isWindows ? 'ipfs.exe' : 'ipfs'

const oldPath = process.env.testpath
before(() => { process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') }) // fake __dirname
after(() => { process.env.testpath = oldPath })

it('has the correct path when installed with npm3', (done) => {
process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname
let npm3Path = path.join(tmp, 'ipfsd-ctl-test/node_modules/go-ipfs-dep/go-ipfs')

mkdirp(npm3Path, (err) => {
Expand All @@ -36,8 +39,6 @@ describe('ipfs executable path', () => {
})

it('has the correct path when installed with npm2', (done) => {
process.env.testpath = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/lib') // fake __dirname

let npm2Path = path.join(tmp, 'ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs')

mkdirp(npm2Path, (err) => {
Expand All @@ -50,9 +51,7 @@ describe('ipfs executable path', () => {
const node = new Daemon()

expect(node.exec)
.to.eql(
path.join(tmp, `ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/${appName}`)
)
.to.eql(path.join(tmp, `ipfsd-ctl-test/node_modules/ipfsd-ctl/node_modules/go-ipfs-dep/go-ipfs/${appName}`))
rimraf(path.join(tmp, 'ipfsd-ctl-test'), done)
})
})
Expand Down
Loading

0 comments on commit 4d814b1

Please sign in to comment.