Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

collection is all asynchronous, no event emitters and key_map

  • Loading branch information...
commit 30d78f6b9a7f12515963785e9c17a0557a9df98e 1 parent 0ab1dc5
@pgte authored
View
18 LICENSE
@@ -0,0 +1,18 @@
+Copyright 2010 Pedro Teixeira. All rights reserved.
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to
+deal in the Software without restriction, including without limitation the
+rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+sell copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+IN THE SOFTWARE.
View
102 benchmarks/benchmark_collection.js
@@ -3,54 +3,68 @@ module.exports.run = function(benchmark, next) {
var OBJECT_COUNT= 100000;
benchmark.start('opening collection');
- var collection = require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_bench.alf');
- benchmark.end();
- var assert = require('assert');
+ require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_bench.alf', function(err, collection) {
+ if (err) {
+ throw err;
+ }
+
+ benchmark.end();
+ var assert = require('assert');
- var createRandomString = function(string_length) {
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
- var randomstring = '';
- for (var i=0; i<string_length; i++) {
- var rnum = Math.floor(Math.random() * chars.length);
- randomstring += chars.substring(rnum,rnum+1);
- }
- return randomstring;
- };
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
+ };
- var createRandomObject = function() {
- return {
- a: createRandomString(10),
- b: createRandomString(50),
- c: createRandomString(50)
+ var createRandomObject = function() {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(50),
+ c: createRandomString(50)
+ };
};
- };
- benchmark.start('prunning collection');
- collection.prune(function() {
- benchmark.end();
- benchmark.start('populating collection', OBJECT_COUNT);
- for (var i = 0; i < OBJECT_COUNT; i ++) {
- record = createRandomObject();
- collection.write(record);
- }
- benchmark.end();
-
- // wait for flush
- setTimeout(function() {
- var index = 0;
- benchmark.start('reading collection', OBJECT_COUNT);
- collection.read(function(error, record) {
- assert.equal(error, null);
- if (record === null) {
- benchmark.end();
- collection.end();
- next();
- } else {
- index ++;
- }
- });
- }, 2000);
-
+ benchmark.start('prunning collection');
+ collection.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ benchmark.end();
+ benchmark.start('populating collection', OBJECT_COUNT);
+ for (var i = 0; i < OBJECT_COUNT; i ++) {
+ record = createRandomObject();
+ collection.write(record, function(err) {
+ if (err) {
+ throw err;
+ }
+ });
+ }
+ benchmark.end();
+
+ // wait for flush
+ setTimeout(function() {
+ var index = 0;
+ benchmark.start('reading collection', OBJECT_COUNT);
+ collection.read(function(error, record) {
+ assert.equal(error, null);
+ if (record === null) {
+ benchmark.end();
+ collection.end();
+ next();
+ } else {
+ index ++;
+ }
+ });
+ }, 2000);
+
+ });
+
+
});
}
View
109 benchmarks/benchmark_collection_filter.js
@@ -1,60 +1,69 @@
module.exports.run = function(benchmark, next) {
-
- var collection = require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_filter_benchmark.alf');
+
var assert = require('assert');
- var OBJECT_COUNT = 100000;
-
- collection.on('error', function(error) {
- throw error;
- });
+ require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_filter_benchmark.alf', function(err, collection) {
+ if (err) {
+ throw err;
+ }
+ var OBJECT_COUNT = 100000;
- var createRandomString = function(string_length) {
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
- var randomstring = '';
- for (var i=0; i<string_length; i++) {
- var rnum = Math.floor(Math.random() * chars.length);
- randomstring += chars.substring(rnum,rnum+1);
- }
- return randomstring;
- };
-
- var createRandomObject = function(c_value) {
- return {
- a: createRandomString(10),
- b: createRandomString(50),
- c: c_value
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
};
- };
- var compareObjects = function(a, b) {
- return a.a === b.a && a.b === b.b && a.c === b.c;
- };
+ var createRandomObject = function(c_value) {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(50),
+ c: c_value
+ };
+ };
- var c_values = [createRandomString(50), createRandomString(50), createRandomString(50)]
-
- collection.prune(function() {
- for (var i = 0; i < OBJECT_COUNT; i ++) {
- record = createRandomObject(c_values[i % c_values.length]);
- collection.write(record);
- }
+ var compareObjects = function(a, b) {
+ return a.a === b.a && a.b === b.b && a.c === b.c;
+ };
+
+ var c_values = [createRandomString(50), createRandomString(50), createRandomString(50)]
+
+ collection.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ for (var i = 0; i < OBJECT_COUNT; i ++) {
+ record = createRandomObject(c_values[i % c_values.length]);
+ collection.write(record, function(err) {
+ if (err)
+ throw err;
+ });
+ }
+
+ // wait for flush
+ setTimeout(function() {
+ var index = 0;
+ benchmark.start('Collection filter', OBJECT_COUNT);
+ collection.filter(function(record) {
+ return record.c == c_values[1];
+ }, function(error, result) {
+ if (error) {
+ throw error;
+ }
+ if (result === null) {
+ benchmark.end();
+ next();
+ }
+ });
+ }, 2000);
+
+ });
- // wait for flush
- setTimeout(function() {
- var index = 0;
- benchmark.start('Collection filter', OBJECT_COUNT);
- collection.filter(function(record) {
- return record.c == c_values[1];
- }, function(error, result) {
- if (error) {
- throw error;
- }
- benchmark.end();
- next();
- });
- }, 2000);
-
});
+
-}
-
+}
View
87 benchmarks/benchmark_key_map.js
@@ -0,0 +1,87 @@
+module.exports.run = function(benchmark, next) {
+
+ var assert = require('assert');
+
+ require(__dirname + '/../lib/alfred/key_map.js').open(__dirname + '/../tmp/key_map_benchmark.alf', function(err, key_map) {
+ if (err) {
+ throw err;
+ }
+
+ var KEY_COUNT = 50000;
+ var RETRIEVE_RANDOM_COUNT = 10;
+
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
+ };
+
+ var createRandomObject = function() {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(50),
+ c: createRandomString(50)
+ };
+ };
+
+ var compareObjects = function(a, b) {
+ return a.a === b.a && a.b === b.b && a.c === b.c;
+ };
+
+ var keys = [];
+ var map = {};
+
+ key_map.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ benchmark.start('Insert object into key map', KEY_COUNT);
+ for (var i = 0; i < KEY_COUNT; i ++) {
+ var value = createRandomObject();
+ var key = createRandomString(16);
+ keys.push(key);
+ map[key] = value;
+ key_map.put(key, value, function(err) {
+ if (err) {
+ throw err;
+ }
+ });
+ }
+ benchmark.end();
+
+ // wait for flush
+ setTimeout(function() {
+
+ var sample_key_index = Math.floor(Math.random() * KEY_COUNT)
+ var key = keys[sample_key_index];
+ var retrieved_keys = 0;
+
+ benchmark.start('Retrieve a random object by key from a ' + KEY_COUNT + ' hash map', RETRIEVE_RANDOM_COUNT);
+ for(var i = 0; i < RETRIEVE_RANDOM_COUNT; i++) {
+ key_map.get(key, function(err, record) {
+ if (err) {
+ throw err;
+ }
+ retrieved_keys ++;
+ if (retrieved_keys == RETRIEVE_RANDOM_COUNT) {
+ benchmark.end();
+ next();
+ }
+ });
+ }
+
+ // test than when we try to retrieve with a non-existing ket, we get null back
+
+ }, 5000);
+
+ });
+
+ });
+
+
+}
+
View
110 lib/alfred/collection.js
@@ -1,48 +1,81 @@
-var fs = require('fs');
-var carrier = require('carrier');
+var fs = require('fs'),
+ carrier = require('carrier'),
+ assert = require('assert'),
+ path = require('path');
-var open = function(file_path) {
- return fs.createWriteStream(file_path, {
- flags: 'a',
- encoding: 'utf-8'
- });
-}
-
-var Collection = function(file_path) {
+var Collection = function(file_path, callback) {
var self = this;
- this.file_path = file_path;
- this.ws = open(file_path);
- this.ws.on('error', function(error) {
- self.emit('error', error);
+ file_path = path.normalize(file_path);
+ fs.stat(file_path, function(err, stats) {
+ if (err) {
+ callback(err);
+ }
+ self.file_path = file_path;
+ self.write_pos = stats.size;
+ callback();
});
};
-(require('sys') || require('util')).inherits(Collection, require('events').EventEmitter);
-
-module.exports.open = function(file_path) {
- return new Collection(file_path);
+module.exports.open = function(file_path, callback) {
+ var coll = new Collection(file_path, function(err) {
+ if (err) {
+ callback(err);
+ } else {
+ coll.openFile(function(err) {
+ callback(err, coll);
+ });
+ }
+ });
}
-Collection.prototype.reopen = function(callback) {
- this.ws = open(this.file_path);
- if (callback) {
- callback();
- }
+Collection.prototype.openFile = function(callback) {
+ var self = this;
+ fs.open(self.file_path, 'a+', 0666, function(err, fd) {
+ if (err) {
+ callback(err);
+ } else {
+ self.fd = fd;
+ callback(null);
+ }
+ });
};
-Collection.prototype.write = function(record) {
- this.ws.write(JSON.stringify(record) + "\n");
+Collection.prototype.write = function(record, callback) {
+ var str = JSON.stringify(record) + "\n";
+ var length = Buffer.byteLength(str);
+ var buffer = new Buffer(str);
+ fs.write(this.fd, buffer, 0, length, this.write_pos, function(err, written) {
+ if (err) {
+ callback(err);
+ } else {
+ assert.equal(length, written, 'Written length is not the same as predicted length');
+ callback(null);
+ }
+ });
+ this.write_pos += length;
};
-Collection.prototype.end = function() {
- this.ws.end();
+Collection.prototype.end = function(callback) {
+ fs.close(this.fd, callback);
};
-Collection.prototype.prune = function(callback) {
+Collection.prototype.clear = function(callback) {
var self = this;
- self.end();
- fs.unlink(self.file_path, function() {
- self.reopen(callback);
+ self.end(function(err) {
+ if (err) {
+ callback(err);
+ } else {
+ fs.unlink(self.file_path, function(err) {
+ if (err) {
+ callback(err);
+ } else {
+ self.openFile(function(err) {
+ self.write_pos = 0;
+ callback(err);
+ });
+ }
+ });
+ }
});
};
@@ -52,7 +85,11 @@ Collection.prototype.read = function(record_handler) {
record_handler(error);
});
rs.on('end', function() {
- rs = null;
+ try {
+
+ } catch (excp) {
+ rs.destroy();
+ }
record_handler(null, null);
});
carrier.carry(rs, function(line) {
@@ -62,18 +99,17 @@ Collection.prototype.read = function(record_handler) {
};
Collection.prototype.filter = function(filter_function, callback) {
- var records = [];
this.read(function(error, record) {
if (error) {
callback(error);
} else {
- if (record === null) { // reached the end
- callback(null, records);
+ if (record === null) { // reached the end
+ callback(null, null);
} else {
if (filter_function(record)) {
- records.push(record);
+ callback(null, record);
}
}
}
});
-}
+};
View
48 lib/alfred/key_map.js
@@ -0,0 +1,48 @@
+var collection = require('./collection');
+
+var KeyMap = function() {
+};
+
+(require('sys') || require('util')).inherits(KeyMap, require('events').EventEmitter);
+
+module.exports.open = function(file_path, callback) {
+ var key_map = new KeyMap();
+ collection.open(file_path, function(err, coll) {
+ if (err) {
+ callback(err);
+ } else {
+ key_map.collection = coll;
+ callback(null, key_map);
+ }
+ });
+};
+
+KeyMap.prototype.put = function(key, value, callback) {
+ this.collection.write({
+ key: key,
+ value: value,
+ created: (new Date()).getTime()
+ },
+ callback);
+};
+
+KeyMap.prototype.get = function(key, callback) {
+ var value = null;
+ this.collection.filter(function(record) {
+ return record.key === key;
+ }, function(error, record) {
+ if (error) {
+ callback(error);
+ return;
+ }
+ if (record === null) {
+ callback(null, value);
+ } else {
+ value = record.value;
+ }
+ });
+};
+
+KeyMap.prototype.clear = function(callback) {
+ this.collection.clear(callback);
+};
View
28 package.json
@@ -0,0 +1,28 @@
+{ "name" : "alfred"
+, "description" : "Top Secret Stuff"
+, "version" : "0.0.1"
+, "homepage" : "http://github.com/pgte/alfred"
+, "author" : "Pedro Teixeira <pedro.teixeira@gmail.com> (http://www.metaduck.com)"
+, "contributors" :
+ [ "Pedro Teixeira <pedro.teixeira@gmail.com>"
+ ]
+, "repository" :
+ { "type" : "git"
+ , "url" : "http://github.com/pgte/alfred.git"
+ }
+, "bugs" :
+ { "mail" : "pedro.teixeira@gmail.com"
+ , "web" : "http://github.com/pgte/alfred/issues"
+ }
+, "directories" : { "lib" : "./lib" }
+, "engines" : { "node" : ">=0.2.5" }
+, "scripts" : {}
+, "dependencies" :
+ { "carrier" : ">=0.0.4"
+ }
+, "licenses" :
+ [ { "type" : "MIT"
+ , "url" : "http://github.com/pgte/alfred/raw/master/LICENSE"
+ }
+ ]
+}
View
105 test/test_collection.js
@@ -1,61 +1,66 @@
module.exports.run = function(next) {
- var collection = require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_test.alf');
var assert = require('assert');
-
- collection.on('error', function(error) {
- throw error;
- });
-
- var createRandomString = function(string_length) {
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
- var randomstring = '';
- for (var i=0; i<string_length; i++) {
- var rnum = Math.floor(Math.random() * chars.length);
- randomstring += chars.substring(rnum,rnum+1);
- }
- return randomstring;
- };
+ require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_test.alf', function(err, collection) {
+ if (err) {
+ throw err;
+ }
+
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
+ };
- var createRandomObject = function() {
- return {
- a: createRandomString(10),
- b: createRandomString(100),
- c: createRandomString(100)
+ var createRandomObject = function() {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(100),
+ c: createRandomString(100)
+ };
};
- };
- var compareObjects = function(a, b) {
- return a.a === b.a && a.b === b.b && a.c === b.c;
- };
+ var records = [];
- var records = [];
-
- collection.prune(function() {
- for (var i = 0; i < 1000; i ++) {
- record = createRandomObject()
- records.push(record);
- collection.write(record);
- }
-
- // wait for flush
- setTimeout(function() {
- var index = 0;
- collection.read(function(error, record) {
- assert.equal(error, null);
- if(record === null) {
- // reached the end
- assert.equal(records.length, index);
- collection.end();
- next();
- } else {
- assert.ok(compareObjects(record, records[index], "Object at index " + index + ' differs.'));
- index ++;
- }
- });
- }, 2000);
-
+ collection.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ for (var i = 0; i < 1000; i ++) {
+ var record = createRandomObject();
+ records.push(record);
+ collection.write(record, function(err) {
+ if (err) {
+ throw err
+ }
+ });
+ }
+
+ // wait for flush
+ setTimeout(function() {
+ var index = 0;
+ collection.read(function(error, record) {
+ assert.equal(error, null);
+ if(record === null) {
+ // reached the end
+ assert.equal(records.length, index);
+ collection.end();
+ next();
+ } else {
+ assert.deepEqual(record, records[index], "Object at index " + index + ' differs.');
+ index ++;
+ }
+ });
+ }, 2000);
+
+ });
+
});
+
}
View
107 test/test_collection_filter.js
@@ -1,58 +1,73 @@
module.exports.run = function(next) {
-
- var collection = require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_filter_test.alf');
var assert = require('assert');
- var OBJECT_COUNT = 900;
-
- collection.on('error', function(error) {
- throw error;
- });
+ require(__dirname + '/../lib/alfred/collection.js').open(__dirname + '/../tmp/collection_filter_test.alf', function(err, collection) {
- var createRandomString = function(string_length) {
- var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
- var randomstring = '';
- for (var i=0; i<string_length; i++) {
- var rnum = Math.floor(Math.random() * chars.length);
- randomstring += chars.substring(rnum,rnum+1);
- }
- return randomstring;
- };
-
- var createRandomObject = function(c_value) {
- return {
- a: createRandomString(10),
- b: createRandomString(100),
- c: c_value
+ if (err) {
+ throw err;
+ }
+
+ var OBJECT_COUNT = 900;
+
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
};
- };
- var compareObjects = function(a, b) {
- return a.a === b.a && a.b === b.b && a.c === b.c;
- };
+ var createRandomObject = function(c_value) {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(100),
+ c: c_value
+ };
+ };
- var c_values = [createRandomString(100), createRandomString(100), createRandomString(100)]
-
- collection.prune(function() {
- for (var i = 0; i < OBJECT_COUNT; i ++) {
- record = createRandomObject(c_values[i % c_values.length]);
- collection.write(record);
- }
+ var compareObjects = function(a, b) {
+ return a.a === b.a && a.b === b.b && a.c === b.c;
+ };
+
+ var c_values = [createRandomString(100), createRandomString(100), createRandomString(100)]
+
+ collection.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ for (var i = 0; i < OBJECT_COUNT; i ++) {
+ var record = createRandomObject(c_values[i % c_values.length]);
+ collection.write(record, function(err) {
+ if (err) {
+ throw err;
+ }
+ });
+ }
+
+ // wait for flush
+ setTimeout(function() {
+ var result_count = 0;
+ collection.filter(function(record) {
+ return record.c == c_values[1];
+ }, function(error, record) {
+ if (error) {
+ throw error;
+ }
+ if (record === null) {
+ assert.equal(result_count, OBJECT_COUNT / 3);
+ } else {
+ result_count ++;
+ }
+
+ });
+ }, 2000);
+
+ });
- // wait for flush
- setTimeout(function() {
- var index = 0;
- collection.filter(function(record) {
- return record.c == c_values[1];
- }, function(error, result) {
- if (error) {
- throw error;
- }
- assert.equal(result.length, OBJECT_COUNT / 3);
- });
- }, 2000);
-
});
+
}
View
91 test/test_key_map.js
@@ -0,0 +1,91 @@
+module.exports.run = function(next) {
+
+ var assert = require('assert');
+
+ require(__dirname + '/../lib/alfred/key_map.js').open(__dirname + '/../tmp/key_map_test.alf', function(err, key_map) {
+
+ if (err) {
+ throw err;
+ }
+
+ var createRandomString = function(string_length) {
+ var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
+ var randomstring = '';
+ for (var i=0; i<string_length; i++) {
+ var rnum = Math.floor(Math.random() * chars.length);
+ randomstring += chars.substring(rnum,rnum+1);
+ }
+ return randomstring;
+ };
+
+ var createRandomObject = function() {
+ return {
+ a: createRandomString(10),
+ b: createRandomString(100),
+ c: createRandomString(100)
+ };
+ };
+
+ var map = {};
+ var key_count = 0;
+
+ key_map.clear(function(err) {
+ if (err) {
+ throw err;
+ }
+ for (var i = 0; i < 100; i ++) {
+ var value = createRandomObject();
+ var key = createRandomString(16);
+ map[key] = value;
+ key_map.put(key, value, function(err) {
+ if (err) {
+ throw err;
+ }
+ });
+ key_count ++;
+ }
+
+ // wait for flush
+ setTimeout(function() {
+
+ // test if we can retrieve all keys
+ var tested_keys = 0;
+ var tested_null = false;
+ for(var key in map) {
+ (function(key) {
+ key_map.get(key, function(error, result) {
+ if (error) {
+ throw error;
+ }
+ assert.deepEqual(map[key], result);
+ tested_keys ++;
+ });
+ })(key);
+ }
+
+ // test null
+ key_map.get(createRandomString(20), function(error, result) {
+ if (error) {
+ throw error;
+ }
+ assert.equal(null, result);
+ tested_null = true;
+ });
+
+ setTimeout(function() {
+ assert.equal(key_count, tested_keys, 'tested keys is not equal to original key count');
+ assert.equal(true, tested_null, 'did not reach the test null');
+ next();
+ }, 3000);
+
+ // test than when we try to retrieve with a non-existing ket, we get null back
+ }, 2000);
+
+ });
+
+
+ });
+
+
+}
+
Please sign in to comment.
Something went wrong with that request. Please try again.