Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Run generator tests for RethinkDB #172

Merged
merged 5 commits into from Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -3,3 +3,5 @@ services: mongodb
node_js:
- 6
- node
addons:
rethinkdb: 2.3
23 changes: 23 additions & 0 deletions generators/connection/templates/rethinkdb.js
Expand Up @@ -6,6 +6,29 @@ module.exports = function() {
const app = this;
const config = app.get('rethinkdb');
const r = rethinkdbdash(config);
const oldSetup = app.setup;

app.set('rethinkdbClient', r);

app.setup = function(...args) {
let promise = Promise.resolve();

// Go through all services and call the RethinkDB `init`
// which creates the database and tables if they do not exist
Object.keys(app.services).forEach(path => {
const service = app.service(path);

if(typeof service.init === 'function') {
promise = promise.then(() => service.init());
}
});

// Access the initialization if you want to run queries
// right away that depend on the database and tables being created
this.set('rethinkInit', promise);

promise.then(() => oldSetup.apply(this, args));

return this;
};
};
5 changes: 2 additions & 3 deletions test/generators.test.js
Expand Up @@ -208,7 +208,7 @@ describe('generator-feathers', function() {
assert.jsonFileContent(
path.join(appDir, 'config', 'default.json'), {
rethinkdb: {
database: 'testing',
db: 'testing',
servers: [
{
host: 'localhost',
Expand Down Expand Up @@ -269,8 +269,7 @@ describe('generator-feathers', function() {
it('mongoose', () => testServiceGenerator('mongoose', 'mongodb', '_id'));
it('knex', () => testServiceGenerator('knex', 'sqlite', 'id'));
it('sequelize', () => testServiceGenerator('sequelize', 'sqlite', 'id'));

it.skip('rethinkdb', () => testServiceGenerator('rethinkdb', 'id'));
it('rethinkdb', () => testServiceGenerator('rethinkdb', 'id'));
});

describe('feathers:authentication', () => {
Expand Down