forked from ipfs/js-ipfs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ipfs#536 from ipfs/add-listing-config-profiles
feat: add test and docs for listing config profiles
- Loading branch information
Showing
6 changed files
with
168 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const { getDescribe, getIt, expect } = require('../../utils/mocha') | ||
const waterfall = require('async/waterfall') | ||
|
||
module.exports = (createCommon, options) => { | ||
const describe = getDescribe(options) | ||
const it = getIt(options) | ||
const common = createCommon() | ||
|
||
describe('.config.profiles.apply', function () { | ||
this.timeout(30 * 1000) | ||
let ipfs | ||
|
||
before(function (done) { | ||
// CI takes longer to instantiate the daemon, so we need to increase the | ||
// timeout for the before step | ||
this.timeout(60 * 1000) | ||
|
||
common.setup((err, factory) => { | ||
expect(err).to.not.exist() | ||
factory.spawnNode((err, node) => { | ||
expect(err).to.not.exist() | ||
ipfs = node | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
after((done) => common.teardown(done)) | ||
|
||
it('should apply a config profile', (done) => { | ||
let diff | ||
waterfall([ | ||
(cb) => ipfs.config.profiles.apply('lowpower', cb), | ||
(_diff, cb) => { | ||
diff = _diff | ||
expect(diff.old.Swarm.ConnMgr.LowWater).to.not.equal(diff.new.Swarm.ConnMgr.LowWater) | ||
ipfs.config.get(cb) | ||
}, | ||
(newConfig, cb) => { | ||
expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.new.Swarm.ConnMgr.LowWater) | ||
cb() | ||
} | ||
], done) | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
const { createSuite } = require('../../utils/suite') | ||
|
||
const tests = { | ||
list: require('./list'), | ||
apply: require('./apply') | ||
} | ||
|
||
module.exports = createSuite(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const { getDescribe, getIt, expect } = require('../../utils/mocha') | ||
const waterfall = require('async/waterfall') | ||
|
||
module.exports = (createCommon, options) => { | ||
const describe = getDescribe(options) | ||
const it = getIt(options) | ||
const common = createCommon() | ||
|
||
describe('.config.profiles.list', function () { | ||
this.timeout(30 * 1000) | ||
let ipfs | ||
|
||
before(function (done) { | ||
// CI takes longer to instantiate the daemon, so we need to increase the | ||
// timeout for the before step | ||
this.timeout(60 * 1000) | ||
|
||
common.setup((err, factory) => { | ||
expect(err).to.not.exist() | ||
factory.spawnNode((err, node) => { | ||
expect(err).to.not.exist() | ||
ipfs = node | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
after((done) => common.teardown(done)) | ||
|
||
it('should list config profiles', (done) => { | ||
waterfall([ | ||
(cb) => ipfs.config.profiles.list(cb), | ||
(profiles, cb) => { | ||
expect(profiles).to.be.an('array') | ||
expect(profiles).not.to.be.empty() | ||
|
||
profiles.forEach(profile => { | ||
expect(profile.name).to.be.a('string') | ||
expect(profile.description).to.be.a('string') | ||
}) | ||
|
||
cb() | ||
} | ||
], done) | ||
}) | ||
}) | ||
} |