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

Commit

Permalink
fix: repo stat for string values
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Santos committed Nov 14, 2019
1 parent 72fdc8c commit eef5762
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"browser-process-platform": "~0.1.1",
"cross-env": "^6.0.0",
"go-ipfs-dep": "^0.4.22",
"interface-ipfs-core": "^0.119.0",
"interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/add-human-option-test-repo-stat",
"ipfsd-ctl": "^0.47.1",
"nock": "^11.4.0",
"stream-equal": "^1.1.1"
Expand Down
10 changes: 5 additions & 5 deletions src/repo/stat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
const promisify = require('promisify-es6')
const Big = require('bignumber.js')

const transform = function (res, callback) {
const transform = ({ human }) => (res, callback) => {
callback(null, {
numObjects: new Big(res.NumObjects),
repoSize: new Big(res.RepoSize),
numObjects: human ? res.NumObjects : new Big(res.NumObjects),
repoSize: human ? res.RepoSize : new Big(res.RepoSize),
repoPath: res.RepoPath,
version: res.Version,
storageMax: new Big(res.StorageMax)
storageMax: human ? res.StorageMax : new Big(res.StorageMax)
})
}

Expand All @@ -23,6 +23,6 @@ module.exports = (send) => {
send.andTransform({
path: 'repo/stat',
qs: opts
}, transform, callback)
}, transform(opts), callback)
})
}
9 changes: 8 additions & 1 deletion test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,14 @@ describe('interface-ipfs-core tests', () => {
] : null
})

tests.repo(defaultCommonFactory)
tests.repo(defaultCommonFactory, {
skip: [
{
name: 'should get human readable repo stats',
reason: 'FIXME go-ipfs only has human option implemented for the cli'
}
]
})

tests.stats(defaultCommonFactory)

Expand Down

0 comments on commit eef5762

Please sign in to comment.