Skip to content

Commit

Permalink
:heavy+plus_sign: Expose db handlers from module #7
Browse files Browse the repository at this point in the history
  • Loading branch information
jrans committed Oct 26, 2016
1 parent 1eeacd1 commit 15ad9cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var pg = require('pg');
var parseOptions = require('./parse_options.js');
var instantiateDb = require('./instantiate_db.js');
var configValidator = require('./config_validator.js');
var handlers = require('./db_handlers.js');

exports.register = function (server, options, next) {
var schema = parseOptions.schema(options, server);
Expand All @@ -38,3 +39,5 @@ exports.register = function (server, options, next) {
};

exports.register.attributes = { name: 'abase-db' };

exports.handlers = handlers;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "abase-db",
"version": "0.0.1",
"version": "0.0.2",
"description": "A little experiment in defining models in Joi and creating PostgreSQL Tables",
"main": "lib/index.js",
"devDependencies": {
Expand Down
13 changes: 13 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ test('Can register DB plugin with `schemaPath` option', function (t) {
});
});
});

test('db handlers exposed', function (t) {
var handlers = Object.keys(plugin.handlers);
var wanted = ['insert', 'select', 'delete', 'update', 'init'];

t.ok(
wanted.reduce(function (truth, handler) {
return truth && handlers.indexOf(handler) > -1;
}, true),
'all handlers found: ' + wanted.join(', ')
);
t.end();
});

0 comments on commit 15ad9cc

Please sign in to comment.