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

test: add human readable repo stats test #554

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion src/repo/stat.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-env mocha */
'use strict'

const { expectIsRepo } = require('../stats/utils')
const { expectIsRepo, expectIsRepoHumanized } = require('../stats/utils')
const { getDescribe, getIt, expect } = require('../utils/mocha')

module.exports = (createCommon, options) => {
Expand Down Expand Up @@ -41,5 +41,11 @@ module.exports = (createCommon, options) => {
expectIsRepo(null, res)
})
})

it('should get human readable repo stats', async () => {
const res = await ipfs.repo.stat({ human: true })

expectIsRepoHumanized(null, res)
})
})
}
15 changes: 15 additions & 0 deletions src/stats/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,18 @@ exports.expectIsRepo = (err, res) => {
expect(res.repoPath).to.be.a('string')
expect(res.version).to.be.a('string')
}

exports.expectIsRepoHumanized = (err, res) => {
expect(err).to.not.exist()
expect(res).to.exist()
expect(res).to.have.a.property('numObjects')
expect(res).to.have.a.property('repoSize')
expect(res).to.have.a.property('repoPath')
expect(res).to.have.a.property('version')
expect(res).to.have.a.property('storageMax')
expect(res.numObjects).to.be.a('number')
expect(res.repoSize).to.eql('30.1 kB')
expect(res.storageMax).to.eql('9.01 PB')
expect(res.repoPath).to.be.a('string')
expect(res.version).to.be.a('string')
}