-
Notifications
You must be signed in to change notification settings - Fork 124
Conversation
@@ -0,0 +1,73 @@ | |||
pinning API |
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.
Pinning
##### `JavaScript` - ipfs.pin.rm(hash, [callback]) | ||
|
||
Where `hash` is a multihash. | ||
|
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.
What about recursive? Should be a default true bool.
|
||
describe('callback API', () => { | ||
it('.remove (first, because adding is recursive)', (done) => { | ||
const hash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' |
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.
Make this const declared above, not sure why you declare it so many times.
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 kind of like of having tests that are really self descriptive, it makes it easier to read and to change.
ipfs.pin.rm(hash, { recursive: true }, (err, res) => { | ||
expect(err).to.not.exist | ||
expect(res).to.exist | ||
ipfs.pin.ls({ type: 'direct' }, (err, res) => { |
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.
Try with all different types?
```JavaScript | ||
{ | ||
hash: 'QmHash', | ||
path: 'some-path |
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.
Missing '.
Thank you @RichardLitt :D Applied almost all your CR, will add a couple more tests to cover remaining cases :) |
@@ -0,0 +1,91 @@ | |||
Pin API |
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.
The folder is called pinning-api
, so this probably should be called Pinning API
4730c36
to
981f803
Compare
Applied all the CR :) |
Where: | ||
- `hash` is a multihash. | ||
- `options` is an object that can contain the following keys | ||
- `recursive` - Recursively unpin the object linked. Type: bool. Default: 'false' |
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.
'false' -> false
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.
Richard disagreed on that one, I'll let that 🚲🏠 happen on a separate PR
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.
@RichardLitt why? (can't find the comment), 'false' in a markdown document looks like it is a string.
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.
Yeah, that looks fine to me. This should be default true, though!
expect(Object.keys(pinset).length > 0).to.equal(true) | ||
done() | ||
}) | ||
}) |
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.
These three tests above could be simplified to
function testLs (type) {
return it(`.ls type ${type}`, (done) => {
ipfs.pin.ls({type}, (err, pinset) => {
expect(err).to.not.exist
expect(Object.keys(pinset)).to.be.not.empty
done()
})
})
}
testLs('recursive')
testLs('indirect')
testLs('direct')
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.
Simplified, but not simpler for changes, reading, etc :)
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.
fair enough, but please use .not.empty
rather than .length > 0).equal(true)
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.
you got it :)
lgtm |
Works in js-ipfsmilestone 6