mirror of
https://github.com/misskey-dev/misskey.git
synced 2025-01-11 01:00:07 +09:00
fix
This commit is contained in:
parent
c49dfd45e6
commit
d7263bea1b
@ -133,11 +133,13 @@ export const entities = [
|
||||
...charts as any
|
||||
];
|
||||
|
||||
export function initDb(justBorrow = false, sync = false, log = false) {
|
||||
try {
|
||||
const conn = getConnection();
|
||||
return Promise.resolve(conn);
|
||||
} catch (e) {}
|
||||
export function initDb(justBorrow = false, sync = false, log = false, forceRecreate = false) {
|
||||
if (!forceRecreate) {
|
||||
try {
|
||||
const conn = getConnection();
|
||||
return Promise.resolve(conn);
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return createConnection({
|
||||
type: 'postgres',
|
||||
|
@ -26,15 +26,15 @@ import * as _TestUniqueChart from '../src/services/chart/charts/schemas/test-uni
|
||||
import { Connection, getConnection, createConnection } from 'typeorm';
|
||||
import config from '../src/config';
|
||||
import Chart from '../src/services/chart/core';
|
||||
import { initDb } from '../src/db/postgre';
|
||||
|
||||
function initDb() {
|
||||
function initChartDb() {
|
||||
try {
|
||||
const conn = getConnection('__for_chart_testing');
|
||||
const conn = getConnection();
|
||||
return Promise.resolve(conn);
|
||||
} catch (e) {}
|
||||
|
||||
return createConnection({
|
||||
name: '__for_chart_testing',
|
||||
type: 'postgres',
|
||||
host: config.db.host,
|
||||
port: config.db.port,
|
||||
@ -59,12 +59,17 @@ describe('Chart', () => {
|
||||
let connection: Connection;
|
||||
|
||||
before(done => {
|
||||
initDb().then(c => {
|
||||
initChartDb().then(c => {
|
||||
connection = c;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
after(async(async () => {
|
||||
await connection.close();
|
||||
await initDb(true, undefined, undefined, true);
|
||||
}));
|
||||
|
||||
beforeEach(done => {
|
||||
testChart = new TestChart();
|
||||
testGroupedChart = new TestGroupedChart();
|
||||
|
Loading…
Reference in New Issue
Block a user