From d5c4a4fb956edb6f4c0c901ab6f3d7f78345761f Mon Sep 17 00:00:00 2001 From: Dom Harrington Date: Tue, 24 Feb 2015 10:25:23 +0000 Subject: [PATCH] Expose `idType` in memory engine Without this, the API between memory-backed services have a different API to `save-mongodb` services, which can cause test failures. --- lib/memory-engine.js | 11 +++++++++++ test/engine.tests.js | 1 + test/id-type.js | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 test/id-type.js diff --git a/lib/memory-engine.js b/lib/memory-engine.js index 2d1479a..e44afd0 100644 --- a/lib/memory-engine.js +++ b/lib/memory-engine.js @@ -283,6 +283,16 @@ module.exports = function (opts) { }) } + /** + * Casts an id to the type required by the database + * + * @param {String} the value to cast + * @api public + */ + function idType(value) { + return value + } + extend(self , { create: create , read: read @@ -294,6 +304,7 @@ module.exports = function (opts) { , count: count , idProperty: options.idProperty , createOrUpdate: createOrUpdate + , idType: idType }) return self diff --git a/test/engine.tests.js b/test/engine.tests.js index 0f6a785..4ef15d3 100644 --- a/test/engine.tests.js +++ b/test/engine.tests.js @@ -28,6 +28,7 @@ module.exports = function (idProperty, getEngine, beforeCallback, afterCallback) , './count' , './create-or-update' , './streaming' + , './id-type' ].map(function(testFile) { require(testFile)(idProperty, getEngine) }) diff --git a/test/id-type.js b/test/id-type.js new file mode 100644 index 0000000..44a5f34 --- /dev/null +++ b/test/id-type.js @@ -0,0 +1,14 @@ +var assert = require('assert') + +module.exports = function(idProperty, getEngine) { + + describe('#idType()', function () { + it('should return a function', function (done) { + getEngine(function (error, engine) { + assert.equal(typeof engine.idType, 'function') + done() + }) + }) + }) + +}