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

Commit 50eabf6

Browse files
author
Pedro Santos
committed
refactor: files-mfs before and after methods to async syntax
1 parent bc7dcef commit 50eabf6

File tree

13 files changed

+55
-226
lines changed

13 files changed

+55
-226
lines changed

src/files-mfs/cp.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,14 @@ module.exports = (createCommon, options) => {
1010
const it = getIt(options)
1111
const common = createCommon()
1212

13-
describe('.files.cp', function () {
14-
this.timeout(40 * 1000)
13+
describe.only('.files.cp', function () {
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
18+
before(async () => { ipfs = await common.setup() })
2219

23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
32-
33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should copy file, expect error', () => {
3623
const testDir = `/test-${hat()}`
@@ -41,7 +28,7 @@ module.exports = (createCommon, options) => {
4128
it('should copy file, expect no error', async () => {
4229
const testDir = `/test-${hat()}`
4330

44-
await ipfs.files.mkdir(testDir, { p: true })
31+
await ipfs.files.mkdir(testDir, { parents: true })
4532
await ipfs.files.write(`${testDir}/a`, Buffer.from('TEST'), { create: true })
4633
await ipfs.files.cp(`${testDir}/a`, `${testDir}/b`)
4734
})
@@ -55,7 +42,7 @@ module.exports = (createCommon, options) => {
5542
it('should copy dir, expect no error', async () => {
5643
const testDir = `/test-${hat()}`
5744

58-
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { p: true })
45+
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { parents: true })
5946
await ipfs.files.cp(`${testDir}/lv1/lv2`, `${testDir}/lv1/lv3`)
6047
})
6148

src/files-mfs/flush.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,13 @@ module.exports = (createCommon, options) => {
1010
const common = createCommon()
1111

1212
describe('.files.flush', function () {
13-
this.timeout(40 * 1000)
13+
this.timeout(60 * 1000)
1414

1515
let ipfs
1616

17-
before(function (done) {
18-
// CI takes longer to instantiate the daemon, so we need to increase the
19-
// timeout for the before step
20-
this.timeout(60 * 1000)
21-
22-
common.setup((err, factory) => {
23-
expect(err).to.not.exist()
24-
factory.spawnNode((err, node) => {
25-
expect(err).to.not.exist()
26-
ipfs = node
27-
done()
28-
})
29-
})
30-
})
17+
before(async () => { ipfs = await common.setup() })
3118

32-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3320

3421
it('should not flush not found file/dir, expect error', async () => {
3522
const testDir = `/test-${hat()}`
@@ -46,7 +33,7 @@ module.exports = (createCommon, options) => {
4633
it('should flush specific dir', async () => {
4734
const testDir = `/test-${hat()}`
4835

49-
await ipfs.files.mkdir(testDir, { p: true })
36+
await ipfs.files.mkdir(testDir, { parents: true })
5037
await ipfs.files.flush(testDir)
5138
})
5239
})

src/files-mfs/ls-pull-stream.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,13 @@ module.exports = (createCommon, options) => {
1111
const common = createCommon()
1212

1313
describe('.files.lsPullStream', function () {
14-
this.timeout(40 * 1000)
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
18+
before(async () => { ipfs = await common.setup() })
3219

33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should not ls not found file/dir, expect error', () => {
3623
const testDir = `/test-${hat()}`
@@ -44,7 +31,7 @@ module.exports = (createCommon, options) => {
4431
it('should ls directory', async () => {
4532
const testDir = `/test-${hat()}`
4633

47-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
34+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
4835
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
4936

5037
const entries = await pullToPromise.any(ipfs.files.lsPullStream(testDir))
@@ -58,7 +45,7 @@ module.exports = (createCommon, options) => {
5845
it('should ls directory with long option', async () => {
5946
const testDir = `/test-${hat()}`
6047

61-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
48+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
6249
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
6350

6451
const entries = await pullToPromise.any(ipfs.files.lsPullStream(testDir, { long: true }))

src/files-mfs/ls-readable-stream.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,13 @@ module.exports = (createCommon, options) => {
1111
const common = createCommon()
1212

1313
describe('.files.lsReadableStream', function () {
14-
this.timeout(40 * 1000)
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
18+
before(async () => { ipfs = await common.setup() })
3219

33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should not ls not found file/dir, expect error', () => {
3623
const testDir = `/test-${hat()}`
@@ -45,7 +32,7 @@ module.exports = (createCommon, options) => {
4532
it('should ls directory', async () => {
4633
const testDir = `/test-${hat()}`
4734

48-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
35+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
4936
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
5037

5138
const stream = ipfs.files.lsReadableStream(testDir)
@@ -61,7 +48,7 @@ module.exports = (createCommon, options) => {
6148
it('should ls directory with long option', async () => {
6249
const testDir = `/test-${hat()}`
6350

64-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
51+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
6552
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
6653

6754
const stream = ipfs.files.lsReadableStream(testDir, { long: true })

src/files-mfs/ls.js

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,13 @@ module.exports = (createCommon, options) => {
1111
const common = createCommon()
1212

1313
describe('.files.ls', function () {
14-
this.timeout(40 * 1000)
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
18+
before(async () => { ipfs = await common.setup() })
3219

33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should not ls not found file/dir, expect error', () => {
3623
const testDir = `/test-${hat()}`
@@ -41,7 +28,7 @@ module.exports = (createCommon, options) => {
4128
it('should ls directory', async () => {
4229
const testDir = `/test-${hat()}`
4330

44-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
31+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
4532
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
4633

4734
const info = await ipfs.files.ls(testDir)
@@ -55,7 +42,7 @@ module.exports = (createCommon, options) => {
5542
it('should ls directory with long option', async () => {
5643
const testDir = `/test-${hat()}`
5744

58-
await ipfs.files.mkdir(`${testDir}/lv1`, { p: true })
45+
await ipfs.files.mkdir(`${testDir}/lv1`, { parents: true })
5946
await ipfs.files.write(`${testDir}/b`, Buffer.from('Hello, world!'), { create: true })
6047

6148
const info = await ipfs.files.ls(testDir, { long: true })

src/files-mfs/mkdir.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,13 @@ module.exports = (createCommon, options) => {
1010
const common = createCommon()
1111

1212
describe('.files.mkdir', function () {
13-
this.timeout(40 * 1000)
13+
this.timeout(60 * 1000)
1414

1515
let ipfs
1616

17-
before(function (done) {
18-
// CI takes longer to instantiate the daemon, so we need to increase the
19-
// timeout for the before step
20-
this.timeout(60 * 1000)
21-
22-
common.setup((err, factory) => {
23-
expect(err).to.not.exist()
24-
factory.spawnNode((err, node) => {
25-
expect(err).to.not.exist()
26-
ipfs = node
27-
done()
28-
})
29-
})
30-
})
17+
before(async () => { ipfs = await common.setup() })
3118

32-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3320

3421
it('should make directory on root', () => {
3522
const testDir = `/test-${hat()}`
@@ -40,7 +27,7 @@ module.exports = (createCommon, options) => {
4027
it('should make directory and its parents', () => {
4128
const testDir = `/test-${hat()}`
4229

43-
return ipfs.files.mkdir(`${testDir}/lv1/lv2`, { p: true })
30+
return ipfs.files.mkdir(`${testDir}/lv1/lv2`, { parents: true })
4431
})
4532

4633
it('should not make already existent directory', () => {

src/files-mfs/mv.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,16 @@ module.exports = (createCommon, options) => {
1010
const common = createCommon()
1111

1212
describe('.files.mv', function () {
13-
this.timeout(40 * 1000)
13+
this.timeout(60 * 1000)
1414

1515
let ipfs
1616

17-
before(function (done) {
18-
// CI takes longer to instantiate the daemon, so we need to increase the
19-
// timeout for the before step
20-
this.timeout(60 * 1000)
21-
22-
common.setup((err, factory) => {
23-
expect(err).to.not.exist()
24-
factory.spawnNode((err, node) => {
25-
expect(err).to.not.exist()
26-
ipfs = node
27-
done()
28-
})
29-
})
30-
})
17+
before(async () => { ipfs = await common.setup() })
3118

3219
before(async () => {
33-
await ipfs.files.mkdir('/test/lv1/lv2', { p: true })
20+
await ipfs.files.mkdir('/test/lv1/lv2', { parents: true })
3421
await ipfs.files.write('/test/a', Buffer.from('Hello, world!'), { create: true })
3522
})
36-
3723
after(() => common.teardown())
3824

3925
it('should not move not found file/dir, expect error', () => {
@@ -45,7 +31,7 @@ module.exports = (createCommon, options) => {
4531
it('should move file, expect no error', async () => {
4632
const testDir = `/test-${hat()}`
4733

48-
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { p: true })
34+
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { parents: true })
4935
await ipfs.files.write(`${testDir}/a`, Buffer.from('Hello, world!'), { create: true })
5036

5137
await ipfs.files.mv(`${testDir}/a`, `${testDir}/c`)
@@ -54,7 +40,7 @@ module.exports = (createCommon, options) => {
5440
it('should move dir, expect no error', async () => {
5541
const testDir = `/test-${hat()}`
5642

57-
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { p: true })
43+
await ipfs.files.mkdir(`${testDir}/lv1/lv2`, { parents: true })
5844
await ipfs.files.mv('/test/lv1/lv2', '/test/lv1/lv4')
5945
})
6046
})

src/files-mfs/read-pull-stream.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,13 @@ module.exports = (createCommon, options) => {
1111
const common = createCommon()
1212

1313
describe('.files.readPullStream', function () {
14-
this.timeout(40 * 1000)
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
18+
before(async () => { ipfs = await common.setup() })
3219

33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should not read not found, expect error', () => {
3623
const testDir = `/test-${hat()}`

src/files-mfs/read-readable-stream.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,13 @@ module.exports = (createCommon, options) => {
1111
const common = createCommon()
1212

1313
describe('.files.readReadableStream', function () {
14-
this.timeout(40 * 1000)
14+
this.timeout(60 * 1000)
1515

1616
let ipfs
1717

18-
before(function (done) {
19-
// CI takes longer to instantiate the daemon, so we need to increase the
20-
// timeout for the before step
21-
this.timeout(60 * 1000)
22-
23-
common.setup((err, factory) => {
24-
expect(err).to.not.exist()
25-
factory.spawnNode((err, node) => {
26-
expect(err).to.not.exist()
27-
ipfs = node
28-
done()
29-
})
30-
})
31-
})
18+
before(async () => { ipfs = await common.setup() })
3219

33-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3421

3522
it('should not read not found, expect error', () => {
3623
const testDir = `/test-${hat()}`

0 commit comments

Comments
 (0)