-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f298764
commit 62b03ef
Showing
11 changed files
with
216 additions
and
65 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 |
---|---|---|
|
@@ -31,3 +31,6 @@ node_modules | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
lib | ||
dist |
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,35 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
node_modules | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
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 |
---|---|---|
@@ -1,13 +1,20 @@ | ||
sudo: false | ||
language: node_js | ||
node_js: | ||
- 'stable' | ||
- 4 | ||
- 5 | ||
|
||
addons: | ||
firefox: 'latest' | ||
# Make sure we have new NPM. | ||
before_install: | ||
- npm install -g npm | ||
|
||
script: | ||
- npm run lint | ||
- npm test | ||
|
||
addons: | ||
firefox: 'latest' | ||
|
||
before_script: | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start |
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,12 @@ | ||
machine: | ||
node: | ||
version: stable | ||
|
||
dependencies: | ||
pre: | ||
- google-chrome --version | ||
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | ||
- sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' | ||
- sudo apt-get update | ||
- sudo apt-get --only-upgrade install google-chrome-stable | ||
- google-chrome --version |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const tape = require('tape') | ||
const tests = require('abstract-blob-store/tests') | ||
|
||
const blob = require('../src/') | ||
|
||
describe('abstract-blob-store', () => { | ||
it('works', (done) => { | ||
const common = { | ||
setup (t, cb) { | ||
cb(null, blob()) | ||
}, | ||
teardown (t, store, obj, cb) { | ||
if (obj) return store.remove(obj, cb) | ||
cb() | ||
} | ||
} | ||
|
||
tape.onFinish(done) | ||
tests(tape, common) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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,93 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const expect = require('chai').expect | ||
const bl = require('bl') | ||
|
||
const blob = require('../src') | ||
|
||
describe('idb-plus-blob-store', () => { | ||
let store | ||
|
||
before(() => { | ||
store = blob() | ||
}) | ||
|
||
describe('createWriteStream', () => { | ||
it('can write over an existing key', (done) => { | ||
const key = 'hello.txt' | ||
const input1 = 'hello' | ||
const input2 = 'world' | ||
|
||
const ws1 = store.createWriteStream({key}, (err, blob) => { | ||
expect(err).to.not.exist | ||
expect(blob.key).to.be.eql(key) | ||
|
||
const ws2 = store.createWriteStream({key}, (err, blob) => { | ||
expect(err).to.not.exist | ||
expect(blob.key).to.be.eql(key) | ||
|
||
const rs = store.createReadStream(blob) | ||
rs.pipe(bl((err, res) => { | ||
expect(err).to.not.exist | ||
expect(res.toString()).to.be.eql(input2) | ||
done() | ||
})) | ||
}) | ||
|
||
ws2.write(input2) | ||
ws2.end() | ||
}) | ||
|
||
ws1.write(input1) | ||
ws1.end() | ||
}) | ||
|
||
it('throws on missing key', (done) => { | ||
store.createWriteStream({}, (err, blob) => { | ||
expect(err.message).to.be.eql('Missing key') | ||
done() | ||
}) | ||
}) | ||
|
||
it('uses name as key', (done) => { | ||
const name = 'hello.txt' | ||
const ws = store.createWriteStream({name}, (err, blob) => { | ||
expect(err).to.not.exist | ||
expect(blob.key).to.be.eql(name) | ||
done() | ||
}) | ||
ws.end() | ||
}) | ||
}) | ||
|
||
describe('createReadStream', () => { | ||
it('throws on missing key', () => { | ||
expect( | ||
() => store.createReadStream({}) | ||
).to.throw( | ||
'Missing key' | ||
) | ||
}) | ||
|
||
it('uses name as key', (done) => { | ||
const name = 'hello.txt' | ||
const ws = store.createWriteStream({name}, (err, blob) => { | ||
expect(err).to.not.exist | ||
expect(blob.key).to.be.eql(name) | ||
|
||
const rs = store.createReadStream({name}) | ||
|
||
rs.pipe(bl((err, res) => { | ||
expect(err).to.not.exist | ||
expect(res.toString()).to.be.eql('hello') | ||
|
||
done() | ||
})) | ||
}) | ||
|
||
ws.write('hello') | ||
ws.end() | ||
}) | ||
}) | ||
}) |