Skip to content

Commit

Permalink
Use buffer-loader on tests instead of raw-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
fbaiodias committed Jan 28, 2016
1 parent b503f35 commit 3bdb73d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"async": "^1.5.2",
"bl": "^1.0.0",
"bs58": "^3.0.0",
"buffer-loader": "^0.0.1",
"chai": "^3.4.1",
"fs-blob-store": "^5.2.1",
"idb-plus-blob-store": "^1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion tests/browser-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const tests = require('./repo-test')
const _ = require('lodash')
const IPFSRepo = require('../src')

const repoContext = require.context('raw!./test-repo', true)
const repoContext = require.context('buffer!./test-repo', true)

const idb = window.indexedDB ||
window.mozIndexedDB ||
Expand All @@ -16,6 +16,7 @@ const idb = window.indexedDB ||
idb.deleteDatabase('ipfs')
idb.deleteDatabase('ipfs/blocks')

// TODO use arrow funtions again when https://github.com/webpack/webpack/issues/1944 is fixed
describe('IPFS Repo Tests on the Browser', function () {
before(function (done) {
var repoData = []
Expand Down
16 changes: 8 additions & 8 deletions tests/repo-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const isNode = !global.window

const fileA = isNode
? fs.readFileSync(process.cwd() + '/tests/test-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')
: new Buffer(require('raw!./test-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data'))
: require('buffer!./test-repo/blocks/12207028/122070286b9afa6620a66f715c7020d68af3d10e1a497971629c07606bfdb812303d.data')

module.exports = function (repo) {
describe('IPFS Repo Tests', () => {
describe('IPFS Repo Tests', function () {
it('check if Repo exists', done => {
repo.exists((err, exists) => {
expect(err).to.not.exist
Expand Down Expand Up @@ -105,10 +105,10 @@ module.exports = function (repo) {
})
})

describe('datastore', () => {
describe('datastore', function () {
const baseFileHash = 'QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVzxTt3qVe'

it('reads block', done => {
it('reads block', function (done) {
const buf = new Buffer(base58.decode(baseFileHash))
repo.datastore.createReadStream(buf)
.pipe(bl((err, data) => {
Expand All @@ -118,7 +118,7 @@ module.exports = function (repo) {
}))
})

it('write a block', done => {
it('write a block', function (done) {
const rnd = 'QmVtU7ths96fMgZ8YSZAbKghyieq7AjxNdcqyVtesthash'
const mh = new Buffer(base58.decode(rnd))
const data = new Buffer('Oh the data')
Expand All @@ -130,7 +130,7 @@ module.exports = function (repo) {
}).end(data)
})

it('block exists', done => {
it('block exists', function (done) {
const buf = new Buffer(base58.decode(baseFileHash))

repo.datastore.exists(buf, (err, exists) => {
Expand All @@ -140,7 +140,7 @@ module.exports = function (repo) {
})
})

it('check for non existent block', done => {
it('check for non existent block', function (done) {
const buf = new Buffer('random buffer')

repo.datastore.exists(buf, (err, exists) => {
Expand All @@ -150,7 +150,7 @@ module.exports = function (repo) {
})
})

it('remove a block', done => {
it('remove a block', function (done) {
const buf = new Buffer(base58.decode(baseFileHash))
repo.datastore.remove(buf, (err) => {
expect(err).to.not.exist
Expand Down

0 comments on commit 3bdb73d

Please sign in to comment.