Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

feat: /api/v0/repo/version #676

Merged
merged 3 commits into from
Jan 24, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/repo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = (arg) => {

return {
gc: require('./gc')(send),
stat: require('./stat')(send)
stat: require('./stat')(send),
version: require('./version')(send)
}
}
16 changes: 16 additions & 0 deletions src/repo/version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict'

const promisify = require('promisify-es6')

module.exports = (send) => {
return promisify((opts, callback) => {
if (typeof (opts) === 'function') {
callback = opts
opts = {}
}
send({
path: 'repo/version',
qs: opts
}, callback)
})
}
17 changes: 17 additions & 0 deletions test/repo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ describe('.repo', function () {
done()
})
})

it('.repo.version', (done) => {
ipfs.repo.version((err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
expect(res).to.have.a.property('Version')
done()
})
})
})

describe('Promise API', () => {
Expand All @@ -59,5 +68,13 @@ describe('.repo', function () {
expect(res).to.have.a.property('RepoSize')
})
})

it('.repo.version', () => {
return ipfs.repo.version()
.then(res => {
expect(res).to.exist()
expect(res).to.have.a.property('Version')
})
})
})
})