-
Notifications
You must be signed in to change notification settings - Fork 124
feat: add progress bar tests #155
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 |
---|---|---|
|
@@ -123,6 +123,28 @@ module.exports = (common) => { | |
}) | ||
}) | ||
|
||
it('BIG buffer with progress', (done) => { | ||
const expectedMultihash = 'Qme79tX2bViL26vNjPsF3DP1R9rMKMvnPYJiKTTKPrXJjq' | ||
|
||
let progCount = 0 | ||
let progress = 0 | ||
const handler = (p) => { | ||
progCount += 1 | ||
progress = p | ||
} | ||
|
||
ipfs.files.add(bigFile, {progress: handler}, (err, res) => { | ||
expect(err).to.not.exist() | ||
expect(res).to.have.length(1) | ||
const file = res[0] | ||
expect(file.hash).to.equal(expectedMultihash) | ||
expect(file.path).to.equal(file.hash) | ||
expect(progCount).to.equal(58) | ||
expect(progress).to.equal(57792) | ||
done() | ||
}) | ||
}) | ||
|
||
it('add a nested dir as array', (done) => { | ||
// Needs https://github.com/ipfs/js-ipfs-api/issues/339 to be fixed | ||
// for js-ipfs-api + go-ipfs | ||
|
@@ -160,6 +182,52 @@ module.exports = (common) => { | |
}) | ||
}) | ||
|
||
it('add a nested dir as array with progress', (done) => { | ||
// Needs https://github.com/ipfs/js-ipfs-api/issues/339 to be fixed | ||
// for js-ipfs-api + go-ipfs | ||
if (!isNode) { return 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. Hm, why only non-node environment? 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. hmm, good question - this is basically a copy of the above tests which carries this flag. Edit: I wonder if its valid for that test as well? 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. @victorbjelkholm check the issue linked in the comments. go-ipfs started error'ing in v0.4.2 @dryajov mind trying running the dir tests (by removing the if clause) against latest go-ipfs and see if this is still an issue? 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. 🔴 @dryajov did you get to try this one too? 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. I did, it seems to still be an issue with the latest master. |
||
|
||
const content = (name) => ({ | ||
path: `test-folder/${name}`, | ||
content: directoryContent[name] | ||
}) | ||
|
||
const emptyDir = (name) => ({ | ||
path: `test-folder/${name}` | ||
}) | ||
|
||
const expectedRootMultihash = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP' | ||
|
||
const dirs = [ | ||
content('pp.txt'), | ||
content('holmes.txt'), | ||
content('jungle.txt'), | ||
content('alice.txt'), | ||
emptyDir('empty-folder'), | ||
content('files/hello.txt'), | ||
content('files/ipfs.txt'), | ||
emptyDir('files/empty') | ||
] | ||
|
||
let progCount = 0 | ||
let progress = 0 | ||
const handler = (p) => { | ||
progCount += 1 | ||
progress = p | ||
} | ||
|
||
ipfs.files.add(dirs, {progress: handler}, (err, res) => { | ||
expect(err).to.not.exist() | ||
const root = res[res.length - 1] | ||
|
||
expect(root.path).to.equal('test-folder') | ||
expect(root.hash).to.equal(expectedRootMultihash) | ||
expect(progCount).to.equal(8) | ||
expect(progress).to.equal(5) | ||
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 has to be wrong. How can a nested dir full of files have a 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. That is indeed wrong, a fix is coming. |
||
done() | ||
}) | ||
}) | ||
|
||
describe('.createAddStream', () => { | ||
it('stream of valid files and dirs', (done) => { | ||
const content = (name) => ({ | ||
|
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.
Is this the actual file size? go-ipfs tends to "add more than needed" in the progress bar, often it shows
10N%
addedThere 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.
I ran all the tests and all have passed, I think this is the actual size. I'll double check tho.
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.
It should test for it.
.to.equal(sizeOfTheFile)
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.
🔴 @dryajov this is now one of the last things to do in order to get the whole thing merged, mind checking for the right size?
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.
I had to switch attention to - ipfs/js-ipfs#1036, since that would be a major missing part of the whole effort. I'll resume this as soon as I get that one squared out.