Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Aaqil <[email protected]>
  • Loading branch information
aaqilniz committed Aug 25, 2024
1 parent 67084f6 commit e5b344f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,65 @@ export class DsDataSource extends juggler.DataSource
`;

exports[`lb4 datasource integration correctly coerces setting input of type object and array with config 1`] = `
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
import {juggler} from '@loopback/repository';
const config = {
name: 'ds',
connector: 'rest',
localConfigOnly: true,
sharedData: {},
forwardErrorToEnvironment: false,
skipInstall: true,
skipCache: true,
skipLocalCache: true,
force: true,
'skip-cache': true,
'skip-install': true,
resolved: '/home/aaqilniz/working-space/patrick/forked/loopback-next/packages/cli/generators/datasource/index.js',
namespace: 'home:aaqilniz:working-space:patrick:forked:loopback-next:packages:cli:datasource',
_: [],
config: '{"name":"ds","connector":"rest","options":"{\\"test\\": \\"value\\"}","operations":"[\\"get\\", \\"post\\"]"}',
yes: true,
'force-install': false,
'ask-answered': false,
c: '{"name":"ds","connector":"rest","options":"{\\"test\\": \\"value\\"}","operations":"[\\"get\\", \\"post\\"]"}',
y: [
'@@_YEOMAN_EMPTY_MARKER_@@',
true
],
options: {
test: 'value'
},
operations: [
'get',
'post'
],
baseURL: null,
crud: false
};
// Observe application's life cycle to disconnect the datasource when
// application is stopped. This allows the application to be shut down
// gracefully. The \`stop()\` method is inherited from \`juggler.DataSource\`.
// Learn more at https://loopback.io/doc/en/lb4/Life-cycle.html
@lifeCycleObserver('datasource')
export class DsDataSource extends juggler.DataSource
implements LifeCycleObserver {
static dataSourceName = 'ds';
static readonly defaultConfig = config;
constructor(
@inject('datasources.config.ds', {optional: true})
dsConfig: object = config,
) {
super(dsConfig);
}
}
`;


exports[`lb4 datasource integration scaffolds correct file with cloudant input 1`] = `
import {inject, lifeCycleObserver, LifeCycleObserver} from '@loopback/core';
Expand Down
13 changes: 13 additions & 0 deletions packages/cli/test/integration/generators/datasource.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ describe('lb4 datasource integration', () => {

checkDataSourceFilesAgainstSnapshot();
});

it('correctly coerces setting input of type object and array with config', async () => {
await testUtils
.executeGenerator(generator)
.inDir(sandbox.path, () => testUtils.givenLBProject(sandbox.path))
.withArguments([
'--config',
`${JSON.stringify(complexCLIInput)}`,
'--yes',
]);

checkDataSourceFilesAgainstSnapshot();
});
});

function checkDataSourceFilesAgainstSnapshot() {
Expand Down

0 comments on commit e5b344f

Please sign in to comment.