-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support to drop the tables, we make use of it in unit tests in …
…an afterEach method
- Loading branch information
1 parent
0d366e3
commit e502606
Showing
6 changed files
with
140 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ eg: node setup.js 'travis_ci_test', 'postgres', '12345', 'acl_', 192.168.56.10, | |
eg: node setup.js null, null, null, 'acl_', null, null, 'postgres://postgres:[email protected]:5432/travis_ci_test' | ||
typically passing db is for use within code (we use it for rebuilding acl in unit tests) | ||
var createTables = require('node_modules/acl-knex/lib/createTables').createTables; | ||
var createTables = require('node_modules/acl-knex/lib/databaseTasks').createTables; | ||
createTables([ | ||
null, | ||
null, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,8 @@ | |
var knex = require('knex'); | ||
var KnexBackend = require('../'); | ||
var tests = require('../node_modules/acl/test/tests'); | ||
var assert = require('chai').assert; | ||
var error = null; | ||
|
||
function run() { | ||
Object.keys(tests).forEach(function (test) { | ||
|
@@ -11,40 +13,122 @@ function run() { | |
} | ||
|
||
describe('Postgres', function () { | ||
describe('with passing db', function () { | ||
before(function (done) { | ||
var self = this; | ||
var db = knex({ | ||
client: 'postgres', | ||
connection: 'postgres://[email protected]:5432/travis_ci_test' | ||
describe('testing setup method', function () { | ||
before(function () { | ||
error = null; | ||
}); | ||
|
||
describe('with passing db', function () { | ||
before(function (done) { | ||
var self = this; | ||
var db = knex({ | ||
client: 'postgres', | ||
connection: 'postgres://[email protected]:5432/travis_ci_test' | ||
}); | ||
new KnexBackend().setup([null, null, null, null, null, null, null, db], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
new KnexBackend().setup([null, null, null, null, null, null, null, db], function(err, db) { | ||
if (err) return done(err); | ||
self.backend = new KnexBackend(db, 'postgres', 'acl_'); | ||
done(); | ||
|
||
it('should create tables in database', function () { | ||
assert(!error); | ||
}); | ||
|
||
describe('and then using teardown method', function () { | ||
before(function (done) { | ||
var self = this; | ||
var db = knex({ | ||
client: 'postgres', | ||
connection: 'postgres://[email protected]:5432/travis_ci_test' | ||
}); | ||
new KnexBackend().teardown([null, null, null, null, null, null, null, db], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should drop tables in database', function () { | ||
assert(!error); | ||
}); | ||
}); | ||
}); | ||
|
||
run(); | ||
}); | ||
describe('with connection string', function () { | ||
before(function (done) { | ||
var self = this; | ||
describe('with connection string', function () { | ||
before(function (done) { | ||
var self = this; | ||
|
||
new KnexBackend().setup([null, null, null, null, null, null, 'postgres://[email protected]:5432/travis_ci_test'], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
new KnexBackend().setup([null, null, null, null, null, null, 'postgres://[email protected]:5432/travis_ci_test'], function(err, db) { | ||
if (err) return done(err); | ||
self.backend = new KnexBackend(db, 'postgres', 'acl_'); | ||
done(); | ||
it('should create tables in database', function () { | ||
assert(!error); | ||
}); | ||
|
||
describe('and then using teardown method', function () { | ||
before(function (done) { | ||
var self = this; | ||
|
||
new KnexBackend().teardown([null, null, null, null, null, null, 'postgres://[email protected]:5432/travis_ci_test'], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should drop tables in database', function () { | ||
assert(!error); | ||
}); | ||
}); | ||
}); | ||
|
||
run(); | ||
describe('without connection string', function () { | ||
before(function (done) { | ||
var self = this; | ||
|
||
new KnexBackend().setup(['travis_ci_test', 'postgres'], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should create tables in database', function () { | ||
assert(!error); | ||
}); | ||
|
||
describe('and then using teardown method', function () { | ||
before(function (done) { | ||
var self = this; | ||
|
||
new KnexBackend().teardown(['travis_ci_test', 'postgres'], function(err, db) { | ||
error = err; | ||
if (err) return done(err); | ||
done(); | ||
}); | ||
}); | ||
|
||
it('should drop tables in database', function () { | ||
assert(!error); | ||
}); | ||
}); | ||
}); | ||
}); | ||
describe('without connection string', function () { | ||
|
||
describe('Acl Test', function () { | ||
before(function (done) { | ||
var self = this; | ||
|
||
new KnexBackend().setup(['travis_ci_test', 'postgres'], function(err, db) { | ||
var db = knex({ | ||
client: 'postgres', | ||
connection: 'postgres://[email protected]:5432/travis_ci_test' | ||
}); | ||
new KnexBackend().setup([null, null, null, null, null, null, null, db], function(err, db) { | ||
if (err) return done(err); | ||
self.backend = new KnexBackend(db, 'postgres', 'acl_'); | ||
done(); | ||
|