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

Commit dd4752f

Browse files
authored
Merge pull request #391 from ipfs/fix/no-init-docs
test: remove dependency on init doc hashes
2 parents d85883f + ed6c532 commit dd4752f

File tree

2 files changed

+55
-39
lines changed

2 files changed

+55
-39
lines changed

test/interface-ipfs-core/ls.spec.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,49 @@
33

44
const expect = require('chai').expect
55
const isNode = require('detect-node')
6+
const waterfall = require('async/waterfall')
7+
const path = require('path')
8+
69
const FactoryClient = require('../factory/factory-client')
10+
711
describe('ls', function () {
12+
if (!isNode) {
13+
return
14+
}
15+
816
let ipfs
917
let fc
18+
let folder
1019

1120
before(function (done) {
1221
this.timeout(20 * 1000) // slow CI
1322
fc = new FactoryClient()
14-
fc.spawnNode((err, node) => {
15-
expect(err).to.not.exist
16-
ipfs = node
17-
done()
18-
})
23+
waterfall([
24+
(cb) => fc.spawnNode(cb),
25+
(node, cb) => {
26+
ipfs = node
27+
const filesPath = path.join(__dirname, '../data/test-folder')
28+
ipfs.util.addFromFs(filesPath, { recursive: true }, cb)
29+
},
30+
(hashes, cb) => {
31+
folder = hashes[hashes.length - 1].hash
32+
expect(folder).to.be.eql('QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6')
33+
cb()
34+
}
35+
], done)
1936
})
2037

2138
after((done) => {
2239
fc.dismantle(done)
2340
})
2441

2542
it('should correctly retrieve links', function (done) {
26-
if (!isNode) {
27-
return done()
28-
}
29-
30-
ipfs.ls('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG', (err, res) => {
43+
ipfs.ls(folder, (err, res) => {
3144
expect(err).to.not.exist
3245

3346
expect(res).to.have.a.property('Objects')
3447
expect(res.Objects[0]).to.have.a.property('Links')
35-
expect(res.Objects[0]).to.have.property('Hash', 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG')
48+
expect(res.Objects[0]).to.have.property('Hash', 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6')
3649
done()
3750
})
3851
})
@@ -46,8 +59,6 @@ describe('ls', function () {
4659
})
4760

4861
it('should correctly handle a nonexisting path', function (done) {
49-
if (!isNode) return done()
50-
5162
ipfs.ls('QmRNjDeKStKGTQXnJ2NFqeQ9oW/folder_that_isnt_there', (err, res) => {
5263
expect(err).to.exist
5364
expect(res).to.not.exist
@@ -57,13 +68,11 @@ describe('ls', function () {
5768

5869
describe('promise', () => {
5970
it('should correctly retrieve links', () => {
60-
if (!isNode) return
61-
62-
return ipfs.ls('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG')
71+
return ipfs.ls(folder)
6372
.then((res) => {
6473
expect(res).to.have.a.property('Objects')
6574
expect(res.Objects[0]).to.have.a.property('Links')
66-
expect(res.Objects[0]).to.have.property('Hash', 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG')
75+
expect(res.Objects[0]).to.have.property('Hash', 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6')
6776
})
6877
})
6978

@@ -75,8 +84,6 @@ describe('ls', function () {
7584
})
7685

7786
it('should correctly handle a nonexisting path', () => {
78-
if (!isNode) return
79-
8087
return ipfs.ls('QmRNjDeKStKGTQXnJ3NFqeQ9oW/folder_that_isnt_there')
8188
.catch((err) => {
8289
expect(err).to.exist

test/interface-ipfs-core/refs.spec.js

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,65 @@
33

44
const expect = require('chai').expect
55
const isNode = require('detect-node')
6+
const waterfall = require('async/waterfall')
7+
const path = require('path')
68
const FactoryClient = require('../factory/factory-client')
79

810
describe('.refs', () => {
11+
if (!isNode) {
12+
return
13+
}
14+
915
let ipfs
1016
let fc
17+
let folder
1118

1219
before(function (done) {
1320
this.timeout(20 * 1000) // slow CI
1421
fc = new FactoryClient()
15-
fc.spawnNode((err, node) => {
16-
expect(err).to.not.exist
17-
ipfs = node
18-
done()
19-
})
22+
waterfall([
23+
(cb) => fc.spawnNode(cb),
24+
(node, cb) => {
25+
ipfs = node
26+
const filesPath = path.join(__dirname, '../data/test-folder')
27+
ipfs.util.addFromFs(filesPath, { recursive: true }, cb)
28+
},
29+
(hashes, cb) => {
30+
folder = hashes[hashes.length - 1].hash
31+
expect(folder).to.be.eql('QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6')
32+
cb()
33+
}
34+
], done)
2035
})
2136

2237
after((done) => {
2338
fc.dismantle(done)
2439
})
2540

26-
const folder = 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG'
2741
const result = [{
28-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmZTR5bcpQD7cFgTorqxZDYaew1Wqgfbd2ud9QqGPAkK2V about',
42+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmcUYKmQxmTcFom4R4UZP7FWeQzgJkwcFn51XrvsMy7PE9 add.js',
2943
Err: ''
3044
}, {
31-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmYCvbfNbCwFR45HiNP45rwJgvatpiW38D961L5qAhUM5Y contact',
45+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmNeHxDfQfjVFyYj2iruvysLH9zpp78v3cu1s3BZq1j5hY cat.js',
3246
Err: ''
3347
}, {
34-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmY5heUM5qgRubMDD1og9fhCPA6QdkMp3QCwd4s7gJsyE7 help',
48+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmTYFLz5vsdMpq4XXw1a1pSxujJc9Z5V3Aw1Qg64d849Zy files',
3549
Err: ''
3650
}, {
37-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmdncfsVm2h5Kqq9hPmU7oAVX2zTSVP3L869tgTbPYnsha quick-start',
51+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmY9cxiHqTFoWamkQVkpmmqzBrY3hCBEL2XNu3NtX74Fuu hello-link',
3852
Err: ''
3953
}, {
40-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB readme',
54+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmU7wetVaAqc3Meurif9hcYBHGvQmL5QdpPJYBoZizyTNL ipfs-add.js',
4155
Err: ''
4256
}, {
43-
Ref: 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG QmTumTjvcYCAvRRwQ8sDRxh8ezmrcr88YFU7iYNroGGTBZ security-notes',
57+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmctZfSuegbi2TMFY2y3VQjxsH5JbRBu7XmiLfHNvshhio ls.js',
58+
Err: ''
59+
}, {
60+
Ref: 'QmRNjDeKStKGTQXnJ2NFqeQ9oW23WcpbmvCVrpDHgDg3T6 QmbkMNB6rwfYAxRvnG9CWJ6cKKHEdq2ZKTozyF5FQ7H8Rs version.js',
4461
Err: ''
4562
}]
4663

4764
it('refs', (done) => {
48-
if (!isNode) {
49-
return done()
50-
}
51-
5265
ipfs.refs(folder, {format: '<src> <dst> <linkname>'}, (err, objs) => {
5366
expect(err).to.not.exist
5467
expect(objs).to.eql(result)
@@ -59,10 +72,6 @@ describe('.refs', () => {
5972

6073
describe('promise', () => {
6174
it('refs', () => {
62-
if (!isNode) {
63-
return
64-
}
65-
6675
return ipfs.refs(folder, {format: '<src> <dst> <linkname>'})
6776
.then((objs) => {
6877
expect(objs).to.eql(result)

0 commit comments

Comments
 (0)