Skip to content

Commit

Permalink
fix(audit-service): fix test case
Browse files Browse the repository at this point in the history
fix test case

GH-2088
  • Loading branch information
Surbhi-sharma1 committed May 29, 2024
1 parent 17663d6 commit f332d77
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion services/audit-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Additionally, the audit-service goes beyond basic functionality by offering an a

```bash
npm i @sourceloop/audit-service

```

## Getting Started
Expand Down Expand Up @@ -127,7 +128,6 @@ export class AuditDbDataSource

The migrations required for this service are processed during the installation automatically if you set the `AUDIT_MIGRATION` or `SOURCELOOP_MIGRATION` env variable. The migrations use [`db-migrate`](https://www.npmjs.com/package/db-migrate) with [`db-migrate-pg`](https://www.npmjs.com/package/db-migrate-pg) driver for migrations, so you will have to install these packages to use auto-migration. Please note that if you are using some pre-existing migrations or databases, they may be affected. In such a scenario, it is advised that you copy the migration files in your project root, using the `AUDIT_MIGRATION_COPY` or `SOURCELOOP_MIGRATION_COPY` env variables. You can customize or cherry-pick the migrations in the copied files according to your specific requirements and then apply them to the DB.


Additionally, there is now an option to choose between SQL migration or PostgreSQL migration.
NOTE : for [`@sourceloop/cli`](https://www.npmjs.com/package/@sourceloop/cli?activeTab=readme) users, this choice can be specified during the scaffolding process by selecting the "type of datasource" option.

Expand Down
11 changes: 4 additions & 7 deletions services/audit-service/src/__tests__/helpers/db.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,17 @@ export async function getTestDBRepositories(app: DummyAuditServiceApplication) {

export function getTestAuditController(app: DummyAuditServiceApplication) {
let auditLogExportParam: AnyObject[];
const auditLogExport: AuditLogExportFn = (data: AnyObject[]) => {
auditLogExportParam = data;
return Promise.resolve();
};

function getAuditLogExportParameter() {
return auditLogExportParam;
}

const exportToCsvService: ExportToCsvFn = () =>
Promise.resolve('demoResponse');
const {jobProcessingService} = getTestJobProcessingService(app);
const columnBuilderProvider = new ColumnBuilderProvider();

const auditLogExport: AuditLogExportFn = (data: AnyObject[]) => {
auditLogExportParam = data;
return Promise.resolve();
};
const auditLogController = new AuditController(
auditLogRepository,
jobRepository,
Expand Down
4 changes: 0 additions & 4 deletions services/audit-service/src/controllers/audit.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,6 @@ export class AuditController {
return {message: 'No data to be exported'};
}
const customColumnData = await this.columnBuilderService(result);
// const app = this.ctx.getSync(
// AuditLogExportServiceBindings.EXPORT_AUDIT_LOGS,
// );
// await app(customColumnData);
await this.auditLogExportService(customColumnData);
return {message: 'Audit logs exported successfully.'};
}
Expand Down
1 change: 0 additions & 1 deletion services/audit-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export * from './component';
export * from './enums';
export * from './keys';
export * from './models';
// export * from './providers';
export * from './repositories';
export * from './services';
export * from './types';
5 changes: 0 additions & 5 deletions services/audit-service/src/services/job-processing.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export class JobProcessingService {
public querySelectedFiles: QuerySelectedFilesFn,
@inject(AuditLogExportServiceBindings.EXPORT_AUDIT_LOGS)
public auditLogExportService: AuditLogExportFn,
// @inject.context() private readonly ctx: Context,
@inject(ColumnBuilderServiceBindings.COLUMN_BUILDER)
public columnBuilder: ColumnBuilderFn,
@repository(MappingLogRepository)
Expand Down Expand Up @@ -96,10 +95,6 @@ export class JobProcessingService {

if (job.operation === OperationKey.EXPORT) {
const customColumnData = await this.columnBuilder(finalData);
// const app = this.ctx.getSync(
// AuditLogExportServiceBindings.EXPORT_AUDIT_LOGS,
// );
// await app(customColumnData);
await this.auditLogExportService(customColumnData);
}
job.status = FileStatusKey.COMPLETED;
Expand Down

0 comments on commit f332d77

Please sign in to comment.