Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 293765a

Browse files
committed
Add api running test for ipfs version
1 parent 419e916 commit 293765a

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

src/cli/commands/version.js

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

33
const Command = require('ronin').Command
4-
const IPFS = require('../../ipfs-core')
4+
const utils = require('../utils')
55
const debug = require('debug')
66
const log = debug('cli:version')
77
log.error = debug('cli:version:error')
@@ -26,8 +26,8 @@ module.exports = Command.extend({
2626
},
2727

2828
run: (name) => {
29-
var node = new IPFS()
30-
node.version((err, version) => {
29+
var ipfs = utils.getIPFS()
30+
ipfs.version((err, version) => {
3131
if (err) { return log.error(err) }
3232

3333
console.log(version)

tests/test-cli/test-version.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const expect = require('chai').expect
44
const nexpect = require('nexpect')
5+
const httpAPI = require('../../src/http-api')
56

67
describe('version', () => {
78
describe('api offline', () => {
@@ -17,6 +18,28 @@ describe('version', () => {
1718
})
1819

1920
describe('api running', () => {
20-
// TODO
21+
before((done) => {
22+
httpAPI.start((err) => {
23+
expect(err).to.not.exist
24+
done()
25+
})
26+
})
27+
28+
after((done) => {
29+
httpAPI.stop((err) => {
30+
expect(err).to.not.exist
31+
done()
32+
})
33+
})
34+
35+
it('get the version', (done) => {
36+
nexpect.spawn('node', [process.cwd() + '/src/cli/bin.js', 'version'])
37+
.expect('0.4.0-dev')
38+
.run((err, stdout, exitcode) => {
39+
expect(err).to.not.exist
40+
expect(exitcode).to.equal(0)
41+
done()
42+
})
43+
})
2144
})
2245
})

0 commit comments

Comments
 (0)