Skip to content

Commit

Permalink
fix: transmit databaseSchema in command projects:create (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumedeslandes authored Jul 26, 2021
1 parent c5e069b commit c6fd2e3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/commands/projects/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ class CreateCommand extends AbstractAuthenticatedCommand {
dbConnectionUrl: config.databaseConnectionURL,
dbDialect: config.databaseDialect,
dbHostname: config.databaseHost,
dbPort: config.databasePort,
dbName: config.databaseName,
dbUser: config.databaseUser,
dbPassword: config.databasePassword,
ssl: config.databaseSSL,
dbPort: config.databasePort,
dbSchema: config.databaseSchema,
dbUser: config.databaseUser,
mongodbSrv: config.mongoDBSRV,
ssl: config.databaseSSL,
};

if (!config.databaseDialect && !config.databaseConnectionURL) {
Expand Down
37 changes: 37 additions & 0 deletions test/commands/projects/create.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,43 @@ describe('projects:create', () => {
exitCode: 0,
}));
});

describe('with a non-existent schema', () => {
// eslint-disable-next-line jest/no-hooks
beforeAll(async () => {
const sequelizeHelper = new SequelizeHelper();
await sequelizeHelper.connect(DATABASE_URL_POSTGRESQL_MAX);
await sequelizeHelper.given('customers');
await sequelizeHelper.close();
});

it('should fail', () => testCli({
commandClass: CreateProjectCommand,
commandArgs: ['name'],
env: testEnvWithSecret,
token: 'any',
prompts: [
{
in: makePromptInputList(),
out: {
databaseDialect: 'postgres',
databaseName: 'forestadmin_test_toolbelt-sequelize',
databaseSchema: 'missing_schema',
databaseHost: 'localhost',
databasePort: 54369,
databaseUser: 'forest',
databasePassword: 'secret',
databaseSSL: false,
},
},
],
std: [
{ spinner: '√ Connecting to your database' },
{ err: '× This schema does not exists.' },
],
exitCode: 1,
}));
});
});

describe('catch', () => {
Expand Down

0 comments on commit c6fd2e3

Please sign in to comment.