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

Commit 18888be

Browse files
alanshawdaviddias
authored andcommitted
feat: modular interface tests (#1389)
* chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: add skip for DAG subsystem over HTTP API License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: update interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: disable pubsub tests in the browser License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * feat: uses modular interface tests Reduces code repetition, allows test skipping and running only some tests. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: remove .only License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: skip DHT and MFS tests, add repo tests but skip gc License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * feat: enables ipfs.ls* tests License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: teardown for miscellaneous tests License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: rename generic to miscellaneous License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * feat: add types and util tests (skipped as currently failing) License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: adds comments to skipped tests License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: adds skips License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: fixes spawn args to key tests License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: misc tests do not require teardown License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * fix: remove unnecessary skip License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: re-add bitswap tests License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: add test skip reasons License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
1 parent 9c60909 commit 18888be

30 files changed

+353
-885
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"expose-loader": "~0.7.5",
7474
"form-data": "^2.3.2",
7575
"hat": "0.0.3",
76-
"interface-ipfs-core": "~0.69.2",
76+
"interface-ipfs-core": "~0.70.2",
7777
"ipfsd-ctl": "~0.37.3",
7878
"mocha": "^5.1.1",
7979
"ncp": "^2.0.0",

test/core/interface.spec.js

+155
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/* eslint-env mocha */
2+
'use strict'
3+
4+
const tests = require('interface-ipfs-core')
5+
const CommonFactory = require('../utils/interface-common-factory')
6+
const isNode = require('detect-node')
7+
8+
describe('interface-ipfs-core tests', () => {
9+
const defaultCommonFactory = CommonFactory.create()
10+
11+
tests.bitswap(defaultCommonFactory, { skip: !isNode })
12+
13+
tests.block(defaultCommonFactory)
14+
15+
tests.bootstrap(defaultCommonFactory)
16+
17+
tests.config(defaultCommonFactory)
18+
19+
tests.dag(defaultCommonFactory)
20+
21+
tests.dht(defaultCommonFactory, {
22+
skip: { reason: 'TODO: DHT is not implemented in js-ipfs yet!' }
23+
})
24+
25+
tests.files(defaultCommonFactory, {
26+
skip: [
27+
{
28+
name: 'cp',
29+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
30+
},
31+
{
32+
name: 'mkdir',
33+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
34+
},
35+
{
36+
name: 'stat',
37+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
38+
},
39+
{
40+
name: 'rm',
41+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
42+
},
43+
{
44+
name: 'read',
45+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
46+
},
47+
{
48+
name: 'readReadableStream',
49+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
50+
},
51+
{
52+
name: 'readPullStream',
53+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
54+
},
55+
{
56+
name: 'write',
57+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
58+
},
59+
{
60+
name: 'mv',
61+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
62+
},
63+
{
64+
name: 'flush',
65+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
66+
},
67+
{
68+
name: 'ls',
69+
reason: 'TODO: MFS is not implemented in js-ipfs yet!'
70+
}
71+
]
72+
})
73+
74+
tests.key(CommonFactory.create({
75+
spawnOptions: {
76+
args: ['--pass ipfs-is-awesome-software'],
77+
initOptions: { bits: 512 }
78+
}
79+
}))
80+
81+
tests.ls(defaultCommonFactory)
82+
83+
tests.miscellaneous(CommonFactory.create({
84+
// No need to stop, because the test suite does a 'stop' test.
85+
createTeardown: () => cb => cb()
86+
}))
87+
88+
tests.object(defaultCommonFactory)
89+
90+
tests.pin(defaultCommonFactory)
91+
92+
tests.ping(defaultCommonFactory, {
93+
skip: isNode ? null : {
94+
reason: 'FIXME: ping implementation requires DHT'
95+
}
96+
})
97+
98+
tests.pubsub(CommonFactory.create({
99+
spawnOptions: {
100+
args: ['--enable-pubsub-experiment'],
101+
initOptions: { bits: 512 }
102+
}
103+
}), {
104+
skip: isNode ? null : {
105+
reason: 'FIXME: disabled because no swarm addresses'
106+
}
107+
})
108+
109+
tests.repo(defaultCommonFactory, {
110+
skip: [
111+
// repo.gc
112+
{
113+
name: 'gc',
114+
reason: 'TODO: repo.gc is not implemented in js-ipfs yet!'
115+
}
116+
]
117+
})
118+
119+
tests.stats(defaultCommonFactory)
120+
121+
tests.swarm(CommonFactory.create({
122+
createSetup ({ ipfsFactory, nodes }) {
123+
return callback => {
124+
callback(null, {
125+
spawnNode (repoPath, config, cb) {
126+
if (typeof repoPath === 'function') {
127+
cb = repoPath
128+
repoPath = undefined
129+
}
130+
131+
if (typeof config === 'function') {
132+
cb = config
133+
config = undefined
134+
}
135+
136+
const spawnOptions = { repoPath, config, initOptions: { bits: 512 } }
137+
138+
ipfsFactory.spawn(spawnOptions, (err, _ipfsd) => {
139+
if (err) {
140+
return cb(err)
141+
}
142+
143+
nodes.push(_ipfsd)
144+
cb(null, _ipfsd.api)
145+
})
146+
}
147+
})
148+
}
149+
}
150+
}), { skip: !isNode })
151+
152+
tests.types(defaultCommonFactory, { skip: { reason: 'FIXME: currently failing' } })
153+
154+
tests.util(defaultCommonFactory, { skip: { reason: 'FIXME: currently failing' } })
155+
})

test/core/interface/bitswap.js

-35
This file was deleted.

test/core/interface/block.js

-35
This file was deleted.

test/core/interface/bootstrap.js

-35
This file was deleted.

test/core/interface/config.js

-35
This file was deleted.

test/core/interface/dag.js

-35
This file was deleted.

test/core/interface/dht.js

-32
This file was deleted.

0 commit comments

Comments
 (0)