fix tests
This commit is contained in:
@@ -113,20 +113,20 @@ export class MetaService implements OnApplicationShutdown {
|
||||
|
||||
if (before) {
|
||||
await transactionalEntityManager.update(MiMeta, before.id, data);
|
||||
|
||||
const metas = await transactionalEntityManager.find(MiMeta, {
|
||||
order: {
|
||||
id: 'DESC',
|
||||
},
|
||||
});
|
||||
|
||||
return metas[0];
|
||||
} else {
|
||||
return await transactionalEntityManager.save(MiMeta, {
|
||||
await transactionalEntityManager.save(MiMeta, {
|
||||
...data,
|
||||
id: 'x',
|
||||
});
|
||||
}
|
||||
|
||||
const afters = await transactionalEntityManager.find(MiMeta, {
|
||||
order: {
|
||||
id: 'DESC',
|
||||
},
|
||||
});
|
||||
|
||||
return afters[0];
|
||||
});
|
||||
|
||||
if (data.hiddenTags) {
|
||||
|
@@ -4,7 +4,6 @@
|
||||
*/
|
||||
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { IsNull } from 'typeorm';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import type { MiMeta, UsersRepository } from '@/models/_.js';
|
||||
import { SignupService } from '@/core/SignupService.js';
|
||||
|
@@ -6,9 +6,12 @@
|
||||
import { Inject, Injectable } from '@nestjs/common';
|
||||
import { DataSource } from 'typeorm';
|
||||
import * as Redis from 'ioredis';
|
||||
import { LoggerService } from '@/core/LoggerService.js';
|
||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { resetDb } from '@/misc/reset-db.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['non-productive'],
|
||||
@@ -36,13 +39,27 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||
|
||||
@Inject(DI.redis)
|
||||
private redisClient: Redis.Redis,
|
||||
|
||||
private loggerService: LoggerService,
|
||||
private metaService: MetaService,
|
||||
private globalEventService: GlobalEventService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (process.env.NODE_ENV !== 'test') throw new Error('NODE_ENV is not a test');
|
||||
|
||||
await redisClient.flushdb();
|
||||
const logger = this.loggerService.getLogger('reset-db');
|
||||
logger.info('---- Resetting database...');
|
||||
|
||||
await this.redisClient.flushdb();
|
||||
await resetDb(this.db);
|
||||
|
||||
// DIコンテナで管理しているmetaのインスタンスには上記のリセット処理が届かないため、
|
||||
// 初期値を流して明示的にリフレッシュする
|
||||
const meta = await this.metaService.fetch(true);
|
||||
this.globalEventService.publishInternalEvent('metaUpdated', { after: meta });
|
||||
|
||||
logger.info('---- Database reset complete.');
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user