-
Notifications
You must be signed in to change notification settings - Fork 299
test: remove dependency on init doc hashes #391
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,36 +3,48 @@ | |
|
||
const expect = require('chai').expect | ||
const isNode = require('detect-node') | ||
const waterfall = require('async/waterfall') | ||
const path = require('path') | ||
|
||
const FactoryClient = require('../factory/factory-client') | ||
|
||
describe('ls', function () { | ||
if (!isNode) { | ||
return | ||
} | ||
|
||
let ipfs | ||
let fc | ||
let folderHash | ||
|
||
before(function (done) { | ||
this.timeout(20 * 1000) // slow CI | ||
fc = new FactoryClient() | ||
fc.spawnNode((err, node) => { | ||
expect(err).to.not.exist | ||
ipfs = node | ||
done() | ||
}) | ||
waterfall([ | ||
(cb) => fc.spawnNode(cb), | ||
(node, cb) => { | ||
ipfs = node | ||
const filesPath = path.join(__dirname, '../data/test-folder') | ||
ipfs.util.addFromFs(filesPath, { recursive: true }, cb) | ||
}, | ||
(hashes, cb) => { | ||
folderHash = hashes[hashes.length - 1].hash | ||
cb() | ||
} | ||
], done) | ||
}) | ||
|
||
after((done) => { | ||
fc.dismantle(done) | ||
}) | ||
|
||
it('should correctly retrieve links', function (done) { | ||
if (!isNode) { | ||
return done() | ||
} | ||
|
||
ipfs.ls('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG', (err, res) => { | ||
ipfs.ls(folderHash, (err, res) => { | ||
expect(err).to.not.exist | ||
|
||
expect(res).to.have.a.property('Objects') | ||
expect(res.Objects[0]).to.have.a.property('Links') | ||
expect(res.Objects[0]).to.have.property('Hash', 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG') | ||
expect(res.Objects[0]).to.have.property('Hash') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the hash value is not being checked anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
done() | ||
}) | ||
}) | ||
|
@@ -46,8 +58,6 @@ describe('ls', function () { | |
}) | ||
|
||
it('should correctly handle a nonexisting path', function (done) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works all in the browser now? Sweet! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, I just moved the |
||
if (!isNode) return done() | ||
|
||
ipfs.ls('QmRNjDeKStKGTQXnJ2NFqeQ9oW/folder_that_isnt_there', (err, res) => { | ||
expect(err).to.exist | ||
expect(res).to.not.exist | ||
|
@@ -57,13 +67,11 @@ describe('ls', function () { | |
|
||
describe('promise', () => { | ||
it('should correctly retrieve links', () => { | ||
if (!isNode) return | ||
|
||
return ipfs.ls('QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG') | ||
return ipfs.ls(folderHash) | ||
.then((res) => { | ||
expect(res).to.have.a.property('Objects') | ||
expect(res.Objects[0]).to.have.a.property('Links') | ||
expect(res.Objects[0]).to.have.property('Hash', 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG') | ||
expect(res.Objects[0]).to.have.property('Hash') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
}) | ||
}) | ||
|
||
|
@@ -75,8 +83,6 @@ describe('ls', function () { | |
}) | ||
|
||
it('should correctly handle a nonexisting path', () => { | ||
if (!isNode) return | ||
|
||
return ipfs.ls('QmRNjDeKStKGTQXnJ3NFqeQ9oW/folder_that_isnt_there') | ||
.catch((err) => { | ||
expect(err).to.exist | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although we should use the value returned to make sure we are fetching the correct one, we should also have the expected hash hard coded, we've captured bugs in the past because the browser was adding different stuff then what it was added in Node.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed