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

Commit 1888bf5

Browse files
committed
test: update config profile tests
1 parent 36d393c commit 1888bf5

File tree

2 files changed

+34
-50
lines changed

2 files changed

+34
-50
lines changed

src/config/profiles/apply.js

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
'use strict'
33

44
const { getDescribe, getIt, expect } = require('../../utils/mocha')
5-
const waterfall = require('async/waterfall')
65

76
module.exports = (createCommon, options) => {
87
const describe = getDescribe(options)
@@ -30,41 +29,32 @@ module.exports = (createCommon, options) => {
3029

3130
after((done) => common.teardown(done))
3231

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')
4748
})
4849

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)
6858
})
6959
})
7060
}

src/config/profiles/list.js

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
'use strict'
33

44
const { getDescribe, getIt, expect } = require('../../utils/mocha')
5-
const waterfall = require('async/waterfall')
65

76
module.exports = (createCommon, options) => {
87
const describe = getDescribe(options)
@@ -30,21 +29,16 @@ module.exports = (createCommon, options) => {
3029

3130
after((done) => common.teardown(done))
3231

33-
it('should list config profiles', (done) => {
34-
waterfall([
35-
(cb) => ipfs.config.profiles.list(cb),
36-
(profiles, cb) => {
37-
expect(profiles).to.be.an('array')
38-
expect(profiles).not.to.be.empty()
39-
40-
profiles.forEach(profile => {
41-
expect(profile.name).to.be.a('string')
42-
expect(profile.description).to.be.a('string')
43-
})
44-
45-
cb()
46-
}
47-
], done)
32+
it('should list config profiles', async () => {
33+
const profiles = await ipfs.config.profiles.list()
34+
35+
expect(profiles).to.be.an('array')
36+
expect(profiles).not.to.be.empty()
37+
38+
profiles.forEach(profile => {
39+
expect(profile.name).to.be.a('string')
40+
expect(profile.description).to.be.a('string')
41+
})
4842
})
4943
})
5044
}

0 commit comments

Comments
 (0)