diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-05 20:37:24 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2022-06-05 20:37:24 +0900 |
| commit | d17298d3b5b5fb7377ad34fe7c2b8613bbf478de (patch) | |
| tree | 1e6251f9e392abe7547662dbb4093e7de8e14729 /packages/backend/src | |
| parent | Update .mocharc.json (diff) | |
| download | sharkey-d17298d3b5b5fb7377ad34fe7c2b8613bbf478de.tar.gz sharkey-d17298d3b5b5fb7377ad34fe7c2b8613bbf478de.tar.bz2 sharkey-d17298d3b5b5fb7377ad34fe7c2b8613bbf478de.zip | |
fix(test): make chart tests working
Diffstat (limited to 'packages/backend/src')
| -rw-r--r-- | packages/backend/src/db/postgre.ts | 10 | ||||
| -rw-r--r-- | packages/backend/src/services/chart/entities.ts | 12 |
2 files changed, 21 insertions, 1 deletions
diff --git a/packages/backend/src/db/postgre.ts b/packages/backend/src/db/postgre.ts index 50a85d6267..298f6713ea 100644 --- a/packages/backend/src/db/postgre.ts +++ b/packages/backend/src/db/postgre.ts @@ -208,7 +208,15 @@ export const db = new DataSource({ migrations: ['../../migration/*.js'], }); -export async function initDb() { +export async function initDb(force = false) { + if (force) { + if (db.isInitialized) { + await db.destroy(); + } + await db.initialize(); + return; + } + if (db.isInitialized) { // nop } else { diff --git a/packages/backend/src/services/chart/entities.ts b/packages/backend/src/services/chart/entities.ts index 13e994cb65..a9eeabd639 100644 --- a/packages/backend/src/services/chart/entities.ts +++ b/packages/backend/src/services/chart/entities.ts @@ -11,6 +11,11 @@ import { entity as PerUserFollowingChart } from './charts/entities/per-user-foll import { entity as PerUserDriveChart } from './charts/entities/per-user-drive.js'; import { entity as ApRequestChart } from './charts/entities/ap-request.js'; +import { entity as TestChart } from './charts/entities/test.js'; +import { entity as TestGroupedChart } from './charts/entities/test-grouped.js'; +import { entity as TestUniqueChart } from './charts/entities/test-unique.js'; +import { entity as TestIntersectionChart } from './charts/entities/test-intersection.js'; + export const entities = [ FederationChart.hour, FederationChart.day, NotesChart.hour, NotesChart.day, @@ -24,4 +29,11 @@ export const entities = [ PerUserFollowingChart.hour, PerUserFollowingChart.day, PerUserDriveChart.hour, PerUserDriveChart.day, ApRequestChart.hour, ApRequestChart.day, + + ...(process.env.NODE_ENV === 'test' ? [ + TestChart.hour, TestChart.day, + TestGroupedChart.hour, TestGroupedChart.day, + TestUniqueChart.hour, TestUniqueChart.day, + TestIntersectionChart.hour, TestIntersectionChart.day, + ] : []), ]; |