Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat: rework interface tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Jan 19, 2018
1 parent fca2314 commit 3c951bf
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 31 deletions.
21 changes: 19 additions & 2 deletions test/core/interface/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
22 changes: 20 additions & 2 deletions test/core/interface/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

test.config(common)
21 changes: 19 additions & 2 deletions test/core/interface/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
21 changes: 18 additions & 3 deletions test/core/interface/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@

/*
const test = require('interface-ipfs-core')
const parallel = require('async/parallel')
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })
const nodes = []
const common = {
setup: function (callback) {
callback(null, df)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}
nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}
test.dht(common)
*/
21 changes: 19 additions & 2 deletions test/core/interface/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
22 changes: 20 additions & 2 deletions test/core/interface/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

test.generic(common)
21 changes: 19 additions & 2 deletions test/core/interface/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,31 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
22 changes: 20 additions & 2 deletions test/core/interface/pubsub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,32 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (cb) => {
df.spawn({ args: ['--enable-pubsub-experiment'] },
(err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
31 changes: 29 additions & 2 deletions test/core/interface/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,41 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const IPFS = require('../../../src')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create({ remote: false })
const df = DaemonFactory.create({ type: 'proc', exec: IPFS })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'proc', IPFS)
callback(null, {
spawnNode: (repoPath, config, cb) => {
if (typeof repoPath === 'function') {
cb = repoPath
repoPath = undefined
}

if (typeof config === 'function') {
cb = config
config = undefined
}

df.spawn({ repoPath, config }, (err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
20 changes: 18 additions & 2 deletions test/http-api/interface/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const df = DaemonFactory.create({ exec: 'src/cli/bin.js' })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df)
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
20 changes: 18 additions & 2 deletions test/http-api/interface/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@
'use strict'

const test = require('interface-ipfs-core')
const parallel = require('async/parallel')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()
const df = DaemonFactory.create({ exec: 'src/cli/bin.js' })

const nodes = []
const common = {
setup: function (callback) {
callback(null, df, 'js', './src/cli/bin.js')
callback(null, {
spawnNode: (cb) => {
df.spawn((err, _ipfsd) => {
if (err) {
return cb(err)
}

nodes.push(_ipfsd)
cb(null, _ipfsd.api)
})
}
})
},
teardown: function (callback) {
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
}
}

Expand Down
Loading

0 comments on commit 3c951bf

Please sign in to comment.