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

Commit d12c8d5

Browse files
committed
feat(factory): use factory instead, also make files tests to not assume that some files exist in the test repo
1 parent f81a001 commit d12c8d5

File tree

5 files changed

+34
-25
lines changed

5 files changed

+34
-25
lines changed

API/config/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Note that this operation will **not** spark the restart of any service, i.e: if
3535

3636
#### `config.replace`
3737

38-
> Adds or replaces a config value.
38+
> Adds or replaces a config file.
3939
4040
##### `Go` **WIP**
4141

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
"greenkeeperio-bot <support@greenkeeper.io>",
4848
"nginnever <ginneversource@gmail.com>"
4949
]
50-
}
50+
}

src/config.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ module.exports = (common) => {
1010
let ipfs
1111

1212
before((done) => {
13-
common.setup((err, _ipfs) => {
13+
common.setup((err, factory) => {
1414
expect(err).to.not.exist
15-
ipfs = _ipfs
16-
done()
15+
factory.spawnNode((err, node) => {
16+
expect(err).to.not.exist
17+
ipfs = node
18+
done()
19+
})
1720
})
1821
})
1922

src/files.js

+20-17
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@ module.exports = (common) => {
3232
'files/ipfs.txt': fs.readFileSync(path.join(__dirname, './data/test-folder/files/ipfs.txt'))
3333
}
3434

35-
common.setup((err, _ipfs) => {
35+
common.setup((err, factory) => {
3636
expect(err).to.not.exist
37-
ipfs = _ipfs
38-
done()
37+
factory.spawnNode((err, node) => {
38+
expect(err).to.not.exist
39+
ipfs = node
40+
done()
41+
})
3942
})
4043
})
4144

@@ -187,24 +190,24 @@ module.exports = (common) => {
187190

188191
describe('.cat', () => {
189192
it('with a base58 string encoded multihash', (done) => {
190-
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
193+
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
191194
ipfs.cat(hash, (err, stream) => {
192195
expect(err).to.not.exist
193196
stream.pipe(bl((err, data) => {
194197
expect(err).to.not.exist
195-
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
198+
expect(data.toString()).to.contain('Plz add me!')
196199
done()
197200
}))
198201
})
199202
})
200203

201204
it('with a multihash', (done) => {
202-
const mhBuf = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'))
205+
const mhBuf = new Buffer(bs58.decode('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'))
203206
ipfs.cat(mhBuf, (err, stream) => {
204207
expect(err).to.not.exist
205208
stream.pipe(bl((err, data) => {
206209
expect(err).to.not.exist
207-
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
210+
expect(data.toString()).to.contain('Plz add me!')
208211
done()
209212
}))
210213
})
@@ -240,13 +243,13 @@ module.exports = (common) => {
240243

241244
describe('.cat', () => {
242245
it('with a base58 multihash encoded string', () => {
243-
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
246+
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
244247

245248
return ipfs.cat(hash)
246249
.then((stream) => {
247250
stream.pipe(bl((err, data) => {
248251
expect(err).to.not.exist
249-
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
252+
expect(data.toString()).to.contain('Plz add me!')
250253
}))
251254
})
252255
})
@@ -268,12 +271,12 @@ module.exports = (common) => {
268271
})
269272

270273
it('with a multihash', () => {
271-
const hash = new Buffer(bs58.decode('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'))
274+
const hash = new Buffer(bs58.decode('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'))
272275
return ipfs.cat(hash)
273276
.then((stream) => {
274277
stream.pipe(bl((err, data) => {
275278
expect(err).to.not.exist
276-
expect(data.toString()).to.contain('Check out some of the other files in this directory:')
279+
expect(data.toString()).to.contain('Plz add me!')
277280
}))
278281
})
279282
})
@@ -282,31 +285,31 @@ module.exports = (common) => {
282285

283286
describe('.get', () => {
284287
it('with a base58 encoded multihash', (done) => {
285-
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
288+
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
286289
ipfs.files.get(hash, (err, stream) => {
287290
expect(err).to.not.exist
288291
stream.pipe(concat((files) => {
289292
expect(err).to.not.exist
290293
expect(files).to.be.length(1)
291294
expect(files[0].path).to.equal(hash)
292295
files[0].content.pipe(concat((content) => {
293-
expect(content.toString()).to.contain('Check out some of the other files in this directory:')
296+
expect(content.toString()).to.contain('Plz add me!')
294297
done()
295298
}))
296299
}))
297300
})
298301
})
299302

300303
it('with a multihash', (done) => {
301-
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
304+
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
302305
const mhBuf = new Buffer(bs58.decode(hash))
303306
ipfs.files.get(mhBuf, (err, stream) => {
304307
expect(err).to.not.exist
305308
stream.pipe(concat((files) => {
306309
expect(files).to.be.length(1)
307310
expect(files[0].path).to.deep.equal(hash)
308311
files[0].content.pipe(concat((content) => {
309-
expect(content.toString()).to.contain('Check out some of the other files in this directory:')
312+
expect(content.toString()).to.contain('Plz add me!')
310313
done()
311314
}))
312315
}))
@@ -398,14 +401,14 @@ module.exports = (common) => {
398401

399402
describe('promise', () => {
400403
it('with a base58 encoded string', (done) => {
401-
const hash = 'QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB'
404+
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
402405
ipfs.files.get(hash)
403406
.then((stream) => {
404407
stream.pipe(concat((files) => {
405408
expect(files).to.be.length(1)
406409
expect(files[0].path).to.equal(hash)
407410
files[0].content.pipe(concat((content) => {
408-
expect(content.toString()).to.contain('Check out some of the other files in this directory:')
411+
expect(content.toString()).to.contain('Plz add me!')
409412
done()
410413
}))
411414
}))

src/object.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ module.exports = (common) => {
1212
let ipfs
1313

1414
before((done) => {
15-
common.setup((err, _ipfs) => {
15+
common.setup((err, factory) => {
1616
expect(err).to.not.exist
17-
ipfs = _ipfs
18-
done()
17+
factory.spawnNode((err, node) => {
18+
expect(err).to.not.exist
19+
ipfs = node
20+
done()
21+
})
1922
})
2023
})
2124

0 commit comments

Comments
 (0)