|
2 | 2 | 'use strict'
|
3 | 3 |
|
4 | 4 | const { getDescribe, getIt, expect } = require('../../utils/mocha')
|
5 |
| -const waterfall = require('async/waterfall') |
6 | 5 |
|
7 | 6 | module.exports = (createCommon, options) => {
|
8 | 7 | const describe = getDescribe(options)
|
@@ -30,41 +29,32 @@ module.exports = (createCommon, options) => {
|
30 | 29 |
|
31 | 30 | after((done) => common.teardown(done))
|
32 | 31 |
|
33 |
| - it('should apply a config profile', (done) => { |
34 |
| - let diff |
35 |
| - waterfall([ |
36 |
| - (cb) => ipfs.config.profiles.apply('lowpower', cb), |
37 |
| - (_diff, cb) => { |
38 |
| - diff = _diff |
39 |
| - expect(diff.original.Swarm.ConnMgr.LowWater).to.not.equal(diff.updated.Swarm.ConnMgr.LowWater) |
40 |
| - ipfs.config.get(cb) |
41 |
| - }, |
42 |
| - (newConfig, cb) => { |
43 |
| - expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.updated.Swarm.ConnMgr.LowWater) |
44 |
| - cb() |
45 |
| - } |
46 |
| - ], done) |
| 32 | + it('should apply a config profile', async () => { |
| 33 | + const diff = await ipfs.config.profiles.apply('lowpower') |
| 34 | + expect(diff.original.Swarm.ConnMgr.LowWater).to.not.equal(diff.updated.Swarm.ConnMgr.LowWater) |
| 35 | + |
| 36 | + const newConfig = await ipfs.config.get() |
| 37 | + expect(newConfig.Swarm.ConnMgr.LowWater).to.equal(diff.updated.Swarm.ConnMgr.LowWater) |
| 38 | + }) |
| 39 | + |
| 40 | + it('should strip private key from diff output', async () => { |
| 41 | + const originalConfig = await ipfs.config.get() |
| 42 | + const diff = await ipfs.config.profiles.apply('default-networking', { dryRun: true }) |
| 43 | + |
| 44 | + // should have stripped private key from diff output |
| 45 | + expect(originalConfig).to.have.nested.property('Identity.PrivKey') |
| 46 | + expect(diff).to.not.have.nested.property('original.Identity.PrivKey') |
| 47 | + expect(diff).to.not.have.nested.property('updated.Identity.PrivKey') |
47 | 48 | })
|
48 | 49 |
|
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) |
65 |
| - cb() |
66 |
| - } |
67 |
| - ], done) |
| 50 | + it('should not apply a config profile in dry-run mode', async () => { |
| 51 | + const originalConfig = await ipfs.config.get() |
| 52 | + |
| 53 | + await ipfs.config.profiles.apply('server', { dryRun: true }) |
| 54 | + |
| 55 | + const updatedConfig = await ipfs.config.get() |
| 56 | + |
| 57 | + expect(updatedConfig).to.deep.equal(originalConfig) |
68 | 58 | })
|
69 | 59 | })
|
70 | 60 | }
|
0 commit comments