From 89174904bc3d43b501bc1223e48b7310d6609934 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 19 Sep 2022 08:25:44 +0900 Subject: [PATCH] fix(test): fix chart test --- packages/backend/src/core/chart/charts/test-grouped.ts | 6 +++--- .../backend/src/core/chart/charts/test-intersection.ts | 6 +++--- packages/backend/src/core/chart/charts/test-unique.ts | 6 +++--- packages/backend/src/core/chart/charts/test.ts | 6 +++--- packages/backend/test/unit/chart.ts | 10 ++++++---- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/backend/src/core/chart/charts/test-grouped.ts b/packages/backend/src/core/chart/charts/test-grouped.ts index 103cf2a27e..500e85f9f0 100644 --- a/packages/backend/src/core/chart/charts/test-grouped.ts +++ b/packages/backend/src/core/chart/charts/test-grouped.ts @@ -2,8 +2,8 @@ import { Injectable, Inject } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { AppLockService } from '@/core/AppLockService.js'; import { DI } from '@/di-symbols.js'; +import Logger from '@/logger.js'; import Chart from '../core.js'; -import { ChartLoggerService } from '../ChartLoggerService.js'; import { name, schema } from './entities/test-grouped.js'; import type { KVs } from '../core.js'; @@ -20,9 +20,9 @@ export default class TestGroupedChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private chartLoggerService: ChartLoggerService, + private logger: Logger, ) { - super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema, true); + super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema, true); } protected async tickMajor(group: string): Promise>> { diff --git a/packages/backend/src/core/chart/charts/test-intersection.ts b/packages/backend/src/core/chart/charts/test-intersection.ts index 0e38769165..ff63e9976b 100644 --- a/packages/backend/src/core/chart/charts/test-intersection.ts +++ b/packages/backend/src/core/chart/charts/test-intersection.ts @@ -2,8 +2,8 @@ import { Injectable, Inject } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { AppLockService } from '@/core/AppLockService.js'; import { DI } from '@/di-symbols.js'; +import Logger from '@/logger.js'; import Chart from '../core.js'; -import { ChartLoggerService } from '../ChartLoggerService.js'; import { name, schema } from './entities/test-intersection.js'; import type { KVs } from '../core.js'; @@ -18,9 +18,9 @@ export default class TestIntersectionChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private chartLoggerService: ChartLoggerService, + private logger: Logger, ) { - super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema); + super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } protected async tickMajor(): Promise>> { diff --git a/packages/backend/src/core/chart/charts/test-unique.ts b/packages/backend/src/core/chart/charts/test-unique.ts index 44e1b8365d..3be4b0df2b 100644 --- a/packages/backend/src/core/chart/charts/test-unique.ts +++ b/packages/backend/src/core/chart/charts/test-unique.ts @@ -2,8 +2,8 @@ import { Injectable, Inject } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { AppLockService } from '@/core/AppLockService.js'; import { DI } from '@/di-symbols.js'; +import Logger from '@/logger.js'; import Chart from '../core.js'; -import { ChartLoggerService } from '../ChartLoggerService.js'; import { name, schema } from './entities/test-unique.js'; import type { KVs } from '../core.js'; @@ -18,9 +18,9 @@ export default class TestUniqueChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private chartLoggerService: ChartLoggerService, + private logger: Logger, ) { - super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema); + super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } protected async tickMajor(): Promise>> { diff --git a/packages/backend/src/core/chart/charts/test.ts b/packages/backend/src/core/chart/charts/test.ts index 6269674023..89f64c4c1d 100644 --- a/packages/backend/src/core/chart/charts/test.ts +++ b/packages/backend/src/core/chart/charts/test.ts @@ -2,8 +2,8 @@ import { Injectable, Inject } from '@nestjs/common'; import { DataSource } from 'typeorm'; import { AppLockService } from '@/core/AppLockService.js'; import { DI } from '@/di-symbols.js'; +import Logger from '@/logger.js'; import Chart from '../core.js'; -import { ChartLoggerService } from '../ChartLoggerService.js'; import { name, schema } from './entities/test.js'; import type { KVs } from '../core.js'; @@ -20,9 +20,9 @@ export default class TestChart extends Chart { private db: DataSource, private appLockService: AppLockService, - private chartLoggerService: ChartLoggerService, + private logger: Logger, ) { - super(db, (k) => appLockService.getChartInsertLock(k), chartLoggerService.logger, name, schema); + super(db, (k) => appLockService.getChartInsertLock(k), logger, name, schema); } protected async tickMajor(): Promise>> { diff --git a/packages/backend/test/unit/chart.ts b/packages/backend/test/unit/chart.ts index f1159976fd..036d0e19fd 100644 --- a/packages/backend/test/unit/chart.ts +++ b/packages/backend/test/unit/chart.ts @@ -14,6 +14,7 @@ import { entity as TestUniqueChartEntity } from '@/core/chart/charts/entities/te import { entity as TestIntersectionChartEntity } from '@/core/chart/charts/entities/test-intersection.js'; import { loadConfig } from '@/config.js'; import type { AppLockService } from '@/core/AppLockService'; +import Logger from '@/logger.js'; describe('Chart', () => { const config = loadConfig(); @@ -57,10 +58,11 @@ describe('Chart', () => { await db.initialize(); - testChart = new TestChart(db, appLockService); - testGroupedChart = new TestGroupedChart(db, appLockService); - testUniqueChart = new TestUniqueChart(db, appLockService); - testIntersectionChart = new TestIntersectionChart(db, appLockService); + const logger = new Logger('chart'); // TODO: モックにする + testChart = new TestChart(db, appLockService, logger); + testGroupedChart = new TestGroupedChart(db, appLockService, logger); + testUniqueChart = new TestUniqueChart(db, appLockService, logger); + testIntersectionChart = new TestIntersectionChart(db, appLockService, logger); clock = lolex.install({ now: new Date(Date.UTC(2000, 0, 1, 0, 0, 0)),