Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Commit

Permalink
fix: align with main
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter committed Feb 16, 2024
1 parent 66cf07c commit af45d32
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 301 deletions.
2 changes: 1 addition & 1 deletion src/couchdb/couch-db-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { HttpService } from '@nestjs/axios';
import { AxiosHeaders } from 'axios';
import { CouchDbChangesResponse } from './dtos';

@Injectable({})
@Injectable()
export class CouchDbClient {
private readonly logger = new Logger(CouchDbClient.name);

Expand Down
63 changes: 0 additions & 63 deletions src/report-changes/core/couchdb-report-changes.service.spec.ts

This file was deleted.

146 changes: 0 additions & 146 deletions src/report-changes/core/couchdb-report-changes.service.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/report-changes/core/report-change.detector.ts

This file was deleted.

11 changes: 10 additions & 1 deletion src/report/core/sqs-report-calculator.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import { Test, TestingModule } from '@nestjs/testing';
import { SqsReportCalculator } from './sqs-report-calculator.service';
import { DefaultReportStorage } from '../storage/report-storage.service';
import { CouchSqsClient } from '../../couchdb/couch-sqs.client';

describe('SqsReportCalculatorService', () => {
let service: SqsReportCalculator;

let mockCouchSqsClient: { executeQuery: jest.Mock };
let mockReportStorage: { fetchAllReports: jest.Mock };

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [SqsReportCalculator],
providers: [
SqsReportCalculator,
{ provide: CouchSqsClient, useValue: mockCouchSqsClient },
{ provide: DefaultReportStorage, useValue: mockReportStorage },
],
}).compile();

service = module.get<SqsReportCalculator>(SqsReportCalculator);
Expand Down
3 changes: 2 additions & 1 deletion src/report/core/sqs-report-calculator.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
BadRequestException,
Injectable,
InternalServerErrorException,
NotFoundException,
} from '@nestjs/common';
import { ReportCalculator } from './report-calculator';
Expand Down Expand Up @@ -31,7 +32,7 @@ export class SqsReportCalculator implements ReportCalculator {
}

if (report.queries.length === 0) {
throw new BadRequestException();
throw new InternalServerErrorException();
}

return report.queries.flatMap((query) => {
Expand Down
27 changes: 6 additions & 21 deletions src/report/tasks/report-calculation-processor.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ReportCalculationProcessor } from './report-calculation-processor.service';
import { DefaultReportStorage } from '../storage/report-storage.service';
import { HttpModule } from '@nestjs/axios';
import { CouchDbClient } from '../../couchdb/couch-db-client.service';
import { ReportCalculationTask } from './report-calculation-task.service';
import { SqsReportCalculator } from '../core/sqs-report-calculator.service';
import { ReportRepository } from '../repository/report-repository.service';
import { ReportCalculationRepository } from '../repository/report-calculation-repository.service';
import { ConfigService } from '@nestjs/config';

describe('ReportCalculationProcessorService', () => {
let service: ReportCalculationProcessor;

let mockReportStorage: { fetchAllReports: jest.Mock };
let mockSqsReportCalculator: { calculate: jest.Mock };

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
imports: [HttpModule],
imports: [],
providers: [
CouchDbClient,
ReportCalculationTask,
DefaultReportStorage,
ReportCalculationProcessor,
SqsReportCalculator,
ReportRepository,
ReportCalculationRepository,
{
provide: ConfigService,
useValue: {
getOrThrow: jest.fn((key) => {
return 'foo';
}),
},
},
{ provide: DefaultReportStorage, useValue: mockReportStorage },
{ provide: SqsReportCalculator, useValue: mockSqsReportCalculator },
],
}).compile();

Expand Down
31 changes: 11 additions & 20 deletions src/report/tasks/report-calculation-task.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
import { Test, TestingModule } from '@nestjs/testing';
import { ReportCalculationTask } from './report-calculation-task.service';
import { ReportCalculationProcessor } from './report-calculation-processor.service';
import { SqsReportCalculator } from '../core/sqs-report-calculator.service';
import { DefaultReportStorage } from '../storage/report-storage.service';
import { ConfigService } from '@nestjs/config';
import { ReportRepository } from '../repository/report-repository.service';
import { ReportCalculationRepository } from '../repository/report-calculation-repository.service';
import { HttpModule } from '@nestjs/axios';
import { CouchDbClient } from '../../couchdb/couch-db-client.service';

describe('ReportCalculationTaskService', () => {
let service: ReportCalculationTask;

let mockReportCalculationProcessor: {
processNextPendingCalculation: jest.Mock;
};

beforeEach(async () => {
mockReportCalculationProcessor = {
processNextPendingCalculation: jest.fn(),
};

const module: TestingModule = await Test.createTestingModule({
imports: [HttpModule],
imports: [],
providers: [
CouchDbClient,
ReportCalculationTask,
DefaultReportStorage,
ReportCalculationProcessor,
SqsReportCalculator,
ReportRepository,
ReportCalculationRepository,
{
provide: ConfigService,
useValue: {
getOrThrow: jest.fn((key) => {
return 'foo';
}),
},
provide: ReportCalculationProcessor,
useValue: mockReportCalculationProcessor,
},
],
}).compile();
Expand Down

0 comments on commit af45d32

Please sign in to comment.