Skip to content

Commit

Permalink
added first createReadStream test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Aug 3, 2013
1 parent aed81f3 commit a8a7ea3
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/create-read-stream.js
@@ -0,0 +1,32 @@
var tape = require('tape');
var Cache = require('..');
var MemDB = require('memdb');
var through = require('through');

function test (name, fn) {
tape.test(name, function (t) {
var source = MemDB();
var cache = MemDB();
var db = Cache(source, cache);
fn(t, db, source, cache);
});
}

test('reads data from source', function (t, db, source, cache) {
t.plan(4);

source.put('foo', 'bar', function (err) {
t.error(err);
db.createReadStream().pipe(through(write, end));

function write (kv) {
t.equal(kv.key, 'foo');
t.equal(kv.value, 'bar');
}

function end () {
t.ok(true, 'ended');
}
});
});

0 comments on commit a8a7ea3

Please sign in to comment.