Skip to content

Instantly share code, notes, and snippets.

@mikermcneil
Created July 8, 2013 14:05
Show Gist options
  • Save mikermcneil/5949086 to your computer and use it in GitHub Desktop.
Save mikermcneil/5949086 to your computer and use it in GitHub Desktop.
bootstrap.js :: unit test demo for Sails v0.9
/**
* Bootstrap
*/
var Sails = require('sails'),
Utils = require('./utils'),
Database = require('./database'),
localConf = require('../../config/local');
/**
* Before ALL the test bootstrap the server
*/
var app;
before(function(done) {
this.timeout(5000);
// Create the Database
Database.createDatabase(function() {
Sails.lift({
log: {
level: 'error'
},
adapters: {
mysql: {
module: 'sails-mysql',
host: 'localhost',
database: 'name_of_your_database',
user: 'root',
pass: localConf.MYSQL && localConf.MYSQL.PASS || ''
}
}
}, function(err, sails) {
app = sails;
done(err, sails);
});
});
});
/**
* After ALL the tests, lower sails
*/
after(function(done) {
// Remove Testing footprints
Database.dropDatabase(function() {
app.lower(done);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment