From eef5762f9c8eefe5a7f56a3646762b9fe80adc72 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 7 Nov 2019 16:31:41 +0000 Subject: [PATCH] fix: repo stat for string values --- package.json | 2 +- src/repo/stat.js | 10 +++++----- test/interface.spec.js | 9 ++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index acd90bb63..fe25ed912 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/repo/stat.js b/src/repo/stat.js index 2b922de03..22b7de33c 100644 --- a/src/repo/stat.js +++ b/src/repo/stat.js @@ -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) }) } @@ -23,6 +23,6 @@ module.exports = (send) => { send.andTransform({ path: 'repo/stat', qs: opts - }, transform, callback) + }, transform(opts), callback) }) } diff --git a/test/interface.spec.js b/test/interface.spec.js index 760962b38..20218bb9b 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -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)