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

Commit 541a7d5

Browse files
committed
Adding repo API methods supported by ipfs 0.4.1: repo.gc and repo.stat.
1 parent 848cb87 commit 541a7d5

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

src/api/repo.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
const cmds = require('../cmd-helpers')
4+
5+
module.exports = (send) => {
6+
return {
7+
gc: cmds.command(send, 'repo/gc'),
8+
stat: cmds.command(send, 'repo/stat')
9+
}
10+
}

src/load-commands.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ function requireCommands () {
2121
pin: require('./api/pin'),
2222
ping: require('./api/ping'),
2323
refs: require('./api/refs'),
24+
repo: require('./api/repo'),
2425
swarm: require('./api/swarm'),
2526
update: require('./api/update'),
2627
version: require('./api/version')

test/api/repo.spec.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* eslint-env mocha */
2+
/* globals apiClients */
3+
'use strict'
4+
5+
const expect = require('chai').expect
6+
7+
describe('.repo', () => {
8+
it('.repo.gc', (done) => {
9+
apiClients.a.repo.gc((err, res) => {
10+
expect(err).to.not.exist
11+
expect(res).to.exist
12+
done()
13+
})
14+
})
15+
16+
it('.repo.stat', (done) => {
17+
apiClients.a.repo.stat((err, res) => {
18+
expect(err).to.not.exist
19+
expect(res).to.exist
20+
expect(res).to.have.a.property('NumObjects')
21+
expect(res).to.have.a.property('RepoSize')
22+
done()
23+
})
24+
})
25+
26+
describe('promise', () => {
27+
it('.repo.gc', () => {
28+
return apiClients.a.repo.gc()
29+
.then((res) => {
30+
expect(res).to.exist
31+
})
32+
})
33+
34+
it('.repo.stat', () => {
35+
return apiClients.a.repo.stat()
36+
.then((res) => {
37+
expect(res).to.exist
38+
expect(res).to.have.a.property('NumObjects')
39+
expect(res).to.have.a.property('RepoSize')
40+
})
41+
})
42+
})
43+
})

0 commit comments

Comments
 (0)