This repository was archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
add tests for refs endpoint #460
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dc0132e
feat: refs endpoint
dirkmc 7c1fc4f
test: add tests for refs local
dirkmc 4da53ba
test: add tests for refs local pull / streamable
dirkmc 1386b65
test: use expect.includes()
dirkmc 579ea56
fix: async.map -> map
dirkmc e595bde
fix: ref -> Ref
dirkmc ee304a9
chore: add tests for multiple refs, CBOR
dirkmc 50a4eda
chore: add REFS spec
dirkmc ba4f788
test: add test for Object.links with CBOR
dirkmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const pull = require('pull-stream') | ||
|
||
module.exports = (createCommon, options) => { | ||
const ipfsRefsLocal = (ipfs) => { | ||
return (cb) => { | ||
const stream = ipfs.refs.localPullStream() | ||
pull(stream, pull.collect(cb)) | ||
} | ||
} | ||
require('./refs-local-tests')(createCommon, '.refs.localPullStream', ipfsRefsLocal, options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const concat = require('concat-stream') | ||
|
||
module.exports = (createCommon, options) => { | ||
const ipfsRefsLocal = (ipfs) => { | ||
return (cb) => { | ||
const stream = ipfs.refs.localReadableStream() | ||
stream.on('error', cb) | ||
stream.pipe(concat((refs) => cb(null, refs))) | ||
} | ||
} | ||
require('./refs-local-tests')(createCommon, '.refs.localReadableStream', ipfsRefsLocal, options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const { fixtures } = require('./utils') | ||
const { getDescribe, getIt, expect } = require('../utils/mocha') | ||
|
||
module.exports = (createCommon, suiteName, ipfsRefsLocal, options) => { | ||
const describe = getDescribe(options) | ||
const it = getIt(options) | ||
const common = createCommon() | ||
|
||
describe(suiteName, function () { | ||
this.timeout(40 * 1000) | ||
|
||
let ipfs | ||
|
||
before(function (done) { | ||
// CI takes longer to instantiate the daemon, so we need to increase the | ||
// timeout for the before step | ||
this.timeout(60 * 1000) | ||
|
||
common.setup((err, factory) => { | ||
expect(err).to.not.exist() | ||
factory.spawnNode((err, node) => { | ||
expect(err).to.not.exist() | ||
ipfs = node | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
after((done) => common.teardown(done)) | ||
|
||
it('should get local refs', function (done) { | ||
const content = (name) => ({ | ||
path: `test-folder/${name}`, | ||
content: fixtures.directory.files[name] | ||
}) | ||
|
||
const dirs = [ | ||
content('pp.txt'), | ||
content('holmes.txt') | ||
] | ||
|
||
ipfs.add(dirs, (err, res) => { | ||
expect(err).to.not.exist() | ||
|
||
ipfsRefsLocal(ipfs)((err, refs) => { | ||
expect(err).to.not.exist() | ||
|
||
const cids = refs.map(r => r.Ref) | ||
expect(cids.includes('QmVwdDCY4SPGVFnNCiZnX5CtzwWDn6kAM98JXzKxE3kCmn')).to.eql(true) | ||
expect(cids.includes('QmR4nFjTu18TyANgC65ArNWp5Yaab1gPzQ4D8zp7Kx3vhr')).to.eql(true) | ||
dirkmc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
done() | ||
}) | ||
}) | ||
}) | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
module.exports = (createCommon, options) => { | ||
const ipfsRefsLocal = (ipfs) => (cb) => ipfs.refs.local(cb) | ||
require('./refs-local-tests')(createCommon, '.refs.local', ipfsRefsLocal, options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const pull = require('pull-stream') | ||
|
||
module.exports = (createCommon, options) => { | ||
const ipfsRefs = (ipfs) => { | ||
return (path, params, cb) => { | ||
const stream = ipfs.refsPullStream(path, params) | ||
pull(stream, pull.collect(cb)) | ||
} | ||
} | ||
require('./refs-tests')(createCommon, '.refsPullStream', ipfsRefs, options) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const concat = require('concat-stream') | ||
|
||
module.exports = (createCommon, options) => { | ||
const ipfsRefs = (ipfs) => { | ||
return (path, params, cb) => { | ||
const stream = ipfs.refsReadableStream(path, params) | ||
stream.on('error', cb) | ||
stream.pipe(concat((refs) => cb(null, refs))) | ||
} | ||
} | ||
require('./refs-tests')(createCommon, '.refsReadableStream', ipfsRefs, options) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.