Make tests importable

This commit is contained in:
Anatoliy Chakkaev 2013-03-26 04:41:00 +04:00
parent 6981824d28
commit d5d07d8806
7 changed files with 14 additions and 29 deletions

View File

@ -407,10 +407,12 @@ Schema.prototype.defineForeignKey = function defineForeignKey(className, key) {
/**
* Close database connection
*/
Schema.prototype.disconnect = function disconnect() {
Schema.prototype.disconnect = function disconnect(cb) {
if (typeof this.adapter.disconnect === 'function') {
this.connected = false;
this.adapter.disconnect();
this.adapter.disconnect(cb);
} else if (cb) {
cb();
}
};

View File

@ -439,6 +439,8 @@ function validationFailed(inst, v, cb) {
message = message[kind];
} else if (defaultMessages.common[kind]) {
message = defaultMessages.common[kind];
} else {
message = 'is invalid';
}
}
inst.errors.add(attr, message);

View File

@ -2,28 +2,6 @@
var Schema = require('../index').Schema;
var Text = Schema.Text;
// var schemas = {
// // riak: {},
// mysql: {
// database: 'myapp_test',
// username: 'root'
// },
// postgres: {
// database: 'myapp_test',
// username: 'postgres'
// },
// sqlite3: {
// database: ':memory:'
// },
// neo4j: { url: 'http://localhost:7474/' },
// // mongoose: { url: 'mongodb://travis:test@localhost:27017/myapp' },
// mongodb: { url: 'mongodb://travis:test@localhost:27017/myapp' },
// redis2: {},
// memory: {},
// cradle: {},
// nano: { url: 'http://localhost:5984/nano-test' }
// };
var nbSchemaRequests = 0;
var batch;

View File

@ -1,5 +1,4 @@
var Schema = require('../').Schema;
var db = new Schema('memory');
var db = getSchema();
describe('defaults', function() {
var Server;

View File

@ -9,7 +9,7 @@ var j = require('../'),
describe('hooks', function() {
before(function() {
db = new Schema('memory');
db = getSchema();
User = db.define('User', {
email: String,

View File

@ -5,7 +5,7 @@ describe('JSON property', function() {
var schema, Model;
it('should be defined', function() {
schema = new Schema('memory');
schema = getSchema();
Model = schema.define('Model', {propertyName: Schema.JSON});
var m = new Model;
(new Boolean('propertyName' in m)).should.eql(true);

View File

@ -15,7 +15,7 @@ function getValidAttributes() {
describe('validations', function() {
beforeEach(function() {
db = new j.Schema('memory');
db = getSchema();
User = db.define('User', {
email: String,
name: String,
@ -31,6 +31,10 @@ describe('validations', function() {
});
});
afterEach(function() {
db.disconnect();
});
describe('presence', function() {
it('should validate presence', function() {