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

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 122446a069a5
Choose a base ref
...
head repository: ipfs-inactive/js-ipfs-http-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f29ee67a9cc
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 4, 2015

  1. Add object.patch to the API

    samuli committed Nov 4, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    81110f3 View commit details
  2. Fix test for object.patch

    samuli committed Nov 4, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    f194d3e View commit details
  3. Merge pull request #103 from haadcode/master

    Add object.patch to the API
    daviddias committed Nov 4, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    2f29ee6 View commit details
Showing with 41 additions and 5 deletions.
  1. +4 −1 src/index.js
  2. +37 −4 test/tests.js
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -133,7 +133,10 @@ function IpfsAPI (host_or_multiaddr, port) {
},
data: argCommand('object/data'),
stat: argCommand('object/stat'),
links: argCommand('object/links')
links: argCommand('object/links'),
patch: function (file, opts, cb) {
return requestAPI('object/patch', [file].concat(opts), null, null, cb)
}
}

self.swarm = {
41 changes: 37 additions & 4 deletions test/tests.js
Original file line number Diff line number Diff line change
@@ -366,10 +366,10 @@ describe('IPFS Node.js API wrapper tests', function () {
})

describe('.object', function () {
var testObject =
Buffer(JSON.stringify({Data: 'testdata', Links: []}))
var testObjectHash =
'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'
var testObject = Buffer(JSON.stringify({Data: 'testdata', Links: []}))
var testObjectHash = 'QmPTkMuuL6PD8L2SwTwbcs1NPg14U8mRzerB1ZrrBrkSDD'
var testPatchObject = Buffer(JSON.stringify({Data: 'new test data'}))
var testPatchObjectHash = 'QmWJDtdQWQSajQPx1UVAGWKaSGrHVWdjnrNhbooHP7LuF2'

it('object.put', function (done) {
apiClients['a'].object.put(testObject, 'json', function (err, res) {
@@ -448,6 +448,39 @@ describe('IPFS Node.js API wrapper tests', function () {
done()
})
})

it('object.patch', function (done) {
this.timeout(10000)
apiClients['a'].object.put(testPatchObject, 'json', function (err, res) {
if (err) {
throw err
}
apiClients['a'].object.patch(testObjectHash, ['add-link', 'next', testPatchObjectHash], function (err, res) {
if (err) {
throw err
}
var o = JSON.parse(res)
assert.deepEqual(o, {
Hash: 'QmZFdJ3CQsY4kkyQtjoUo8oAzsEs5BNguxBhp8sjQMpgkd',
Links: null
})
apiClients['a'].object.get(o.Hash, function (err, res) {
if (err) {
throw err
}
assert.deepEqual(JSON.parse(res), {
Data: 'testdata',
Links: [{
Name: 'next',
Hash: 'QmWJDtdQWQSajQPx1UVAGWKaSGrHVWdjnrNhbooHP7LuF2',
Size: 15
}]
})
done()
})
})
})
})
})

describe('.swarm', function () {