From 15e1cc042ff33a2ab6f4c7a8d321ca8704f06dc9 Mon Sep 17 00:00:00 2001 From: Arek W Date: Fri, 3 Jan 2014 13:25:12 +1100 Subject: [PATCH] Update test doco & add helpful errors --- README.md | 12 +++++++++++- test/config.example.js | 7 +++---- test/helpers.js | 10 +++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 944016f..548e7f9 100644 --- a/README.md +++ b/README.md @@ -186,10 +186,20 @@ grunt migrate:up --file=001-create-users.js ## Running Tests +Create `test/config.js` (see `test/config.example.js` for instructions) + +```bash +npm test ``` -mocha test +This will run the tests against all configurations inside `config.js`. +To run against a single config: +```bash +ORM_PROTOCOL=mysql node test/run +# OR +ORM_PROTOCOL=mysql mocha test/integration ``` + ## Contributors Locomoters: diff --git a/test/config.example.js b/test/config.example.js index 588f090..ac9aa89 100644 --- a/test/config.example.js +++ b/test/config.example.js @@ -1,11 +1,10 @@ -// To test, rename this file to config.js and update -// the following configuration +// To test, copy this file to test/config.js and update the configuration. // -// To run a single driver, go to root folder and do (mysql example): +// To run a single driver, go to root folder and: // ORM_PROTOCOL=mysql node test/run // // To run all drivers: -// node test/run +// node test/run OR npm test exports.mysql = { protocol : 'mysql', diff --git a/test/helpers.js b/test/helpers.js index d3f0faf..8a346f8 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -25,7 +25,15 @@ module.exports = { var protocol = this.protocol(); if (!(protocol in config)) { - return cb(new Error("Protocol '" + protocol + "' missing in config.js")); + var emsg = ""; + + if (!protocol) { + emsg = "No protocol specified. Specify using: ORM_PROTOCOL=mysql mocha test/integration" + } else { + emsg = "Protocol '" + protocol + "' missing in config.js" + } + + return cb(new Error(emsg)); } orm.connect(config[protocol], function (err, connection) {