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

pinning API #34

Merged
merged 4 commits into from
Aug 16, 2016
Merged

pinning API #34

merged 4 commits into from
Aug 16, 2016

Conversation

daviddias
Copy link
Contributor

@daviddias daviddias commented Jun 28, 2016

WIP

  • API calls
    • ipfs.pin.ls
    • ipfs.pin.add
    • ipfs.pin.rm
  • Works in js-ipfs milestone 6
  • Works in js-ipfs-api

@@ -0,0 +1,73 @@
pinning API
Copy link
Contributor

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.

Copy link
Contributor

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'
Copy link
Contributor

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.

Copy link
Contributor Author

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) => {
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing '.

@daviddias
Copy link
Contributor Author

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
Copy link
Contributor

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

@daviddias daviddias force-pushed the pinning-api branch 3 times, most recently from 4730c36 to 981f803 Compare August 16, 2016 08:54
@daviddias
Copy link
Contributor Author

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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'false' -> false

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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()
})
})
Copy link
Contributor

@dignifiedquire dignifiedquire Aug 16, 2016

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')

Copy link
Contributor Author

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 :)

Copy link
Contributor

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you got it :)

@dignifiedquire
Copy link
Contributor

lgtm

@daviddias daviddias merged commit afbed85 into master Aug 16, 2016
@daviddias daviddias deleted the pinning-api branch August 16, 2016 09:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants