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

Commit 25a99bf

Browse files
author
Pedro Santos
committed
refactor: repo before and after methods to async syntax
1 parent 4479df9 commit 25a99bf

File tree

3 files changed

+16
-46
lines changed

3 files changed

+16
-46
lines changed

src/repo/gc.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,15 @@ module.exports = (createCommon, options) => {
99
const it = getIt(options)
1010
const common = createCommon()
1111

12-
describe('.repo.gc', () => {
12+
describe('.repo.gc', function () {
13+
this.timeout(60 * 1000)
1314
let ipfs
1415

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

30-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3121

3222
it('should run garbage collection', async () => {
3323
const res = await ipfs.add(Buffer.from('apples'))

src/repo/stat.js

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

44
const { expectIsRepo } = require('../stats/utils')
5-
const { getDescribe, getIt, expect } = require('../utils/mocha')
5+
const { getDescribe, getIt } = require('../utils/mocha')
66

77
module.exports = (createCommon, options) => {
88
const describe = getDescribe(options)
99
const it = getIt(options)
1010
const common = createCommon()
1111

12-
describe('.repo.stat', () => {
12+
describe('.repo.stat', function () {
13+
this.timeout(60 * 1000)
1314
let ipfs
1415

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

30-
after((done) => common.teardown(done))
20+
after(() => common.teardown())
3121

3222
it('should get repo stats', async () => {
3323
const res = await ipfs.repo.stat()

src/repo/version.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,15 @@ module.exports = (createCommon, options) => {
88
const it = getIt(options)
99
const common = createCommon()
1010

11-
describe('.repo.version', () => {
11+
describe('.repo.version', function () {
12+
this.timeout(60 * 1000)
1213
let ipfs
1314

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

29-
after((done) => common.teardown(done))
19+
after(() => common.teardown())
3020

3121
it('should get the repo version', async () => {
3222
const version = await ipfs.repo.version()

0 commit comments

Comments
 (0)