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

Commit e206aa7

Browse files
committed
docs: add dry-run config test and change new/old for original/updated
Also corrects `ipfs.config.profiles.list` example. BREAKING CHANGE: `ipfs.config.profiles.apply` now returns `original`/`updated` keys in the diff because using `new` stops us from destructuring in js.
1 parent 04481c9 commit e206aa7

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

SPEC/CONFIG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ If no callback is passed, a [promise][] is returned
101101
**Example:**
102102

103103
```JavaScript
104-
ipfs.config.profiles.list(newConfig, (err, profiles) => {
104+
ipfs.config.profiles.list((err, profiles) => {
105105
if (err) {
106106
throw err
107107
}
@@ -135,8 +135,8 @@ ipfs.config.profiles.apply('lowpower', (err, diff) => {
135135
throw err
136136
}
137137

138-
console.info(diff.old)
139-
console.info(diff.new)
138+
console.info(diff.original)
139+
console.info(diff.updated)
140140
})
141141
```
142142

src/config/profiles/apply.js

+23-2
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,32 @@ module.exports = (createCommon, options) => {
3636
(cb) => ipfs.config.profiles.apply('lowpower', cb),
3737
(_diff, cb) => {
3838
diff = _diff
39-
expect(diff.old.Swarm.ConnMgr.LowWater).to.not.equal(diff.new.Swarm.ConnMgr.LowWater)
39+
expect(diff.original.Swarm.ConnMgr.LowWater).to.not.equal(diff.updated.Swarm.ConnMgr.LowWater)
4040
ipfs.config.get(cb)
4141
},
4242
(newConfig, cb) => {
43-
expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.new.Swarm.ConnMgr.LowWater)
43+
expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.updated.Swarm.ConnMgr.LowWater)
44+
cb()
45+
}
46+
], done)
47+
})
48+
49+
it('should not apply a config profile in dry-run mode', (done) => {
50+
let originalConfig
51+
waterfall([
52+
(cb) => ipfs.config.get(cb),
53+
(config, cb) => {
54+
originalConfig = config
55+
cb()
56+
},
57+
(cb) => ipfs.config.profiles.apply('server', { dryRun: true }, cb),
58+
(diff, cb) => {
59+
expect(diff.original).to.deep.equal(originalConfig)
60+
expect(diff.updated).to.not.deep.equal(originalConfig)
61+
ipfs.config.get(cb)
62+
},
63+
(updatedConfig, cb) => {
64+
expect(updatedConfig).to.deep.equal(originalConfig)
4465
cb()
4566
}
4667
], done)

0 commit comments

Comments
 (0)