From 547a1500f771774cfd745b1c9d42203c52fe4ccf Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 7 Nov 2019 16:51:31 +0000 Subject: [PATCH 1/7] test: add repo-stat tests --- test/cli/repo.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/cli/repo.js b/test/cli/repo.js index f5e47d7eb7..c1f15ed9db 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -16,4 +16,14 @@ describe('repo', () => runOnAndOff((thing) => { const out = await ipfs('repo version') expect(out).to.eql(`${repoVersion}\n`) }) + + it('get repo stats', async () => { + const stats = await ipfs('repo stat') + expect(stats).to.not.include('MB').and.not.include('GB') + }) + + it('get human readable repo stats', async () => { + const stats = await ipfs('repo stat --human') + expect(stats).to.include('MB').and.include('GB') + }) })) From 5256ec95319103aa224a37bfcde72b25c11693d4 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 7 Nov 2019 18:10:37 +0000 Subject: [PATCH 2/7] chore: code review changes --- test/cli/repo.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cli/repo.js b/test/cli/repo.js index c1f15ed9db..6953cbb9a0 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -19,7 +19,8 @@ describe('repo', () => runOnAndOff((thing) => { it('get repo stats', async () => { const stats = await ipfs('repo stat') - expect(stats).to.not.include('MB').and.not.include('GB') + expect(stats).to.match(/^\s+repo\ssize:\s+\d+$/gm) + expect(stats).to.match(/^\s+maximum\sstorage:\s+\d+$/gm) }) it('get human readable repo stats', async () => { From 26d2e81073945b3754b5acbd57269464783a2269 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 14 Nov 2019 11:07:40 +0000 Subject: [PATCH 3/7] chore: update deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 18a7f1be85..1f444dcbc4 100644 --- a/package.json +++ b/package.json @@ -100,11 +100,11 @@ "ipfs-bitswap": "^0.26.0", "ipfs-block": "~0.8.1", "ipfs-block-service": "~0.16.0", - "ipfs-http-client": "^39.0.2", + "ipfs-http-client": "ipfs/js-ipfs-http-client#fix/repo-stat", "ipfs-http-response": "~0.4.0", "ipfs-mfs": "^0.13.0", "ipfs-multipart": "^0.2.0", - "ipfs-repo": "^0.29.0", + "ipfs-repo": "ipfs/js-ipfs-repo#fix/human-readable-option", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-exporter": "^0.38.0", "ipfs-unixfs-importer": "^0.40.0", @@ -204,7 +204,7 @@ "execa": "^3.0.0", "form-data": "^3.0.0", "hat": "0.0.3", - "interface-ipfs-core": "^0.119.0", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/add-human-option-test-repo-stat", "ipfs-interop": "^0.1.1", "ipfsd-ctl": "^0.47.2", "libp2p-websocket-star": "~0.10.2", From 93eff8e95934bae2bd327f8599804d298198364d Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 14 Nov 2019 11:08:28 +0000 Subject: [PATCH 4/7] chore: make stats output consistent with go-ipfs --- src/cli/commands/repo/stat.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cli/commands/repo/stat.js b/src/cli/commands/repo/stat.js index 067dbeb975..a6e0f4adce 100644 --- a/src/cli/commands/repo/stat.js +++ b/src/cli/commands/repo/stat.js @@ -16,12 +16,12 @@ module.exports = { argv.resolve((async () => { const ipfs = await argv.getIpfs() const stats = await ipfs.repo.stat({ human: argv.human }) - argv.print(`repo status - number of objects: ${stats.numObjects} - repo size: ${stats.repoSize} - repo path: ${stats.repoPath} - version: ${stats.version} - maximum storage: ${stats.storageMax}`) + argv.print( +`NumObjects: ${stats.numObjects} +RepoSize: ${stats.repoSize} +StorageMax: ${stats.storageMax} +RepoPath: ${stats.repoPath} +Version: ${stats.version}`) })()) } } From 6b06e0e15652f4f015567562fd5ecc17ac5681f7 Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 14 Nov 2019 11:09:14 +0000 Subject: [PATCH 5/7] fix: fix repo stats tests assertions --- test/cli/repo.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cli/repo.js b/test/cli/repo.js index 6953cbb9a0..1dca583e8a 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -19,12 +19,13 @@ describe('repo', () => runOnAndOff((thing) => { it('get repo stats', async () => { const stats = await ipfs('repo stat') - expect(stats).to.match(/^\s+repo\ssize:\s+\d+$/gm) - expect(stats).to.match(/^\s+maximum\sstorage:\s+\d+$/gm) + expect(stats).to.match(/^RepoSize:\s+\d+$/gm) + expect(stats).to.match(/^StorageMax:\s+\d+$/gm) }) it('get human readable repo stats', async () => { const stats = await ipfs('repo stat --human') - expect(stats).to.include('MB').and.include('GB') + + expect(stats).to.match(/\s.?B$/gm) }) })) From 8e3d32b137cba9e3411ac221366c9b316a80145b Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 14 Nov 2019 15:11:00 +0000 Subject: [PATCH 6/7] chore: improve cli tests --- test/cli/repo.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/cli/repo.js b/test/cli/repo.js index 1dca583e8a..084775244f 100644 --- a/test/cli/repo.js +++ b/test/cli/repo.js @@ -19,13 +19,14 @@ describe('repo', () => runOnAndOff((thing) => { it('get repo stats', async () => { const stats = await ipfs('repo stat') - expect(stats).to.match(/^RepoSize:\s+\d+$/gm) - expect(stats).to.match(/^StorageMax:\s+\d+$/gm) + expect(stats).to.match(/^RepoSize:\s\d+$/gm) + expect(stats).to.match(/^StorageMax:\s\d+$/gm) }) it('get human readable repo stats', async () => { const stats = await ipfs('repo stat --human') - expect(stats).to.match(/\s.?B$/gm) + expect(stats).to.match(/^RepoSize:\s+[\d.]+\s[PTGMK]?B$/gm) + expect(stats).to.match(/^StorageMax:\s+[\d.]+\s[PTGMK]?B$/gm) }) })) From e7514de98fec1deb149f9c091993093d669d64eb Mon Sep 17 00:00:00 2001 From: Pedro Santos Date: Thu, 14 Nov 2019 16:05:18 +0000 Subject: [PATCH 7/7] chore: update ipfs-repo to v0.29.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f444dcbc4..ab7e2e27de 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "ipfs-http-response": "~0.4.0", "ipfs-mfs": "^0.13.0", "ipfs-multipart": "^0.2.0", - "ipfs-repo": "ipfs/js-ipfs-repo#fix/human-readable-option", + "ipfs-repo": "^0.29.1", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-exporter": "^0.38.0", "ipfs-unixfs-importer": "^0.40.0",