-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from nginnever/master
added buffer importer
- Loading branch information
Showing
11 changed files
with
577 additions
and
80 deletions.
There are no files selected for viewing
This file contains 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,19 @@ | ||
|
||
language: node_js | ||
node_js: | ||
- '4' | ||
- '5' | ||
|
||
before_install: | ||
- npm i -g npm | ||
# Workaround for a permissions issue with Travis virtual machine images | ||
|
||
addons: | ||
firefox: 'latest' | ||
|
||
before_script: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
|
||
script: | ||
- npm test |
This file contains 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,54 @@ | ||
const path = require('path') | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
basePath: '', | ||
frameworks: ['mocha'], | ||
|
||
files: [ | ||
'tests/browser.js' | ||
], | ||
|
||
preprocessors: { | ||
'tests/*': ['webpack', 'sourcemap'] | ||
}, | ||
|
||
webpack: { | ||
devtool: 'eval', | ||
resolve: { | ||
extensions: ['', '.js', '.json'] | ||
}, | ||
externals: { | ||
fs: '{}' | ||
}, | ||
node: { | ||
Buffer: true | ||
}, | ||
module: { | ||
loaders: [ | ||
{ test: /\.json$/, loader: 'json' } | ||
], | ||
postLoaders: [ | ||
{ | ||
include: path.resolve(__dirname, 'node_modules/ipfs-unixfs'), | ||
loader: 'transform?brfs' | ||
} | ||
] | ||
} | ||
}, | ||
|
||
webpackMiddleware: { | ||
noInfo: true, | ||
stats: { | ||
colors: true | ||
} | ||
}, | ||
reporters: ['spec'], | ||
port: 9876, | ||
colors: true, | ||
logLevel: config.LOG_INFO, | ||
autoWatch: false, | ||
browsers: process.env.TRAVIS ? ['Firefox'] : ['Chrome'], | ||
singleRun: true | ||
}) | ||
} |
This file contains 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 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 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 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 */ | ||
const tests = require('./buffer-test') | ||
const async = require('async') | ||
const store = require('idb-plus-blob-store') | ||
const _ = require('lodash') | ||
const IPFSRepo = require('ipfs-repo') | ||
const repoContext = require.context('buffer!./repo-example', true) | ||
|
||
const idb = window.indexedDB || | ||
window.mozIndexedDB || | ||
window.webkitIndexedDB || | ||
window.msIndexedDB | ||
|
||
idb.deleteDatabase('ipfs') | ||
idb.deleteDatabase('ipfs/blocks') | ||
|
||
describe('IPFS data importing tests on the Browser', function () { | ||
before(function (done) { | ||
this.timeout(23000) | ||
var repoData = [] | ||
repoContext.keys().forEach(function (key) { | ||
repoData.push({ | ||
key: key.replace('./', ''), | ||
value: repoContext(key) | ||
}) | ||
}) | ||
|
||
const mainBlob = store('ipfs') | ||
const blocksBlob = store('ipfs/blocks') | ||
|
||
async.eachSeries(repoData, (file, cb) => { | ||
if (_.startsWith(file.key, 'datastore/')) { | ||
return cb() | ||
} | ||
|
||
const blocks = _.startsWith(file.key, 'blocks/') | ||
const blob = blocks ? blocksBlob : mainBlob | ||
const key = blocks ? file.key.replace(/^blocks\//, '') : file.key | ||
|
||
blob.createWriteStream({ | ||
key: key | ||
}).end(file.value, cb) | ||
}, done) | ||
}) | ||
|
||
// create the repo constant to be used in the import a small buffer test | ||
const options = { | ||
stores: { | ||
keys: store, | ||
config: store, | ||
datastore: store, | ||
// datastoreLegacy: needs https://github.com/ipfs/js-ipfs-repo/issues/6#issuecomment-164650642 | ||
logs: store, | ||
locks: store, | ||
version: store | ||
} | ||
} | ||
const repo = new IPFSRepo('ipfs', options) | ||
tests(repo) | ||
}) |
Oops, something went wrong.