|
| 1 | +/* eslint-env mocha */ |
| 2 | +/* eslint max-nested-callbacks: ["error", 8] */ |
| 3 | + |
| 4 | +'use strict' |
| 5 | + |
| 6 | +const chai = require('chai') |
| 7 | +const dirtyChai = require('dirty-chai') |
| 8 | +const expect = chai.expect |
| 9 | +chai.use(dirtyChai) |
| 10 | + |
| 11 | +module.exports = (common) => { |
| 12 | + describe('.repo', () => { |
| 13 | + let ipfs |
| 14 | + |
| 15 | + before(function (done) { |
| 16 | + // CI takes longer to instantiate the daemon, so we need to increase the |
| 17 | + // timeout for the before step |
| 18 | + this.timeout(60 * 1000) |
| 19 | + |
| 20 | + common.setup((err, factory) => { |
| 21 | + expect(err).to.not.exist() |
| 22 | + factory.spawnNode((err, node) => { |
| 23 | + expect(err).to.not.exist() |
| 24 | + ipfs = node |
| 25 | + done() |
| 26 | + }) |
| 27 | + }) |
| 28 | + }) |
| 29 | + |
| 30 | + after((done) => { |
| 31 | + common.teardown(done) |
| 32 | + }) |
| 33 | + |
| 34 | + it('.version', (done) => { |
| 35 | + ipfs.repo.version((err, version) => { |
| 36 | + expect(err).to.not.exist() |
| 37 | + expect(version).to.exist() |
| 38 | + done() |
| 39 | + }) |
| 40 | + }) |
| 41 | + |
| 42 | + it('.version Promise', () => { |
| 43 | + return ipfs.repo.version().then((version) => { |
| 44 | + expect(version).to.exist() |
| 45 | + }) |
| 46 | + }) |
| 47 | + |
| 48 | + it('.stat', (done) => { |
| 49 | + ipfs.repo.stat((err, stat) => { |
| 50 | + expect(err).to.not.exist() |
| 51 | + expect(stat).to.exist() |
| 52 | + expect(stat).to.have.property('numObjects') |
| 53 | + expect(stat).to.have.property('repoSize') |
| 54 | + expect(stat).to.have.property('repoPath') |
| 55 | + expect(stat).to.have.property('version') |
| 56 | + expect(stat).to.have.property('storageMax') |
| 57 | + done() |
| 58 | + }) |
| 59 | + }) |
| 60 | + |
| 61 | + it('.stat Promise', () => { |
| 62 | + return ipfs.repo.stat().then((stat) => { |
| 63 | + expect(stat).to.exist() |
| 64 | + expect(stat).to.have.property('numObjects') |
| 65 | + expect(stat).to.have.property('repoSize') |
| 66 | + expect(stat).to.have.property('repoPath') |
| 67 | + expect(stat).to.have.property('version') |
| 68 | + expect(stat).to.have.property('storageMax') |
| 69 | + }) |
| 70 | + }) |
| 71 | + |
| 72 | + it('.gc', (done) => { |
| 73 | + ipfs.repo.gc((err, res) => { |
| 74 | + expect(err).to.not.exist() |
| 75 | + expect(res).to.exist() |
| 76 | + done() |
| 77 | + }) |
| 78 | + }) |
| 79 | + |
| 80 | + it('.gc Promise', () => { |
| 81 | + return ipfs.repo.gc().then((res) => { |
| 82 | + expect(res).to.exist() |
| 83 | + }) |
| 84 | + }) |
| 85 | + }) |
| 86 | +} |
0 commit comments