feat: 完成PHP到NestJS的100%功能迁移
- 迁移25个模块,包含95个控制器和160个服务 - 新增验证码管理、登录配置、云编译等模块 - 完善认证授权、会员管理、支付系统等核心功能 - 实现完整的队列系统、配置管理、监控体系 - 确保100%功能对齐和命名一致性 - 支持生产环境部署
This commit is contained in:
@@ -93,7 +93,10 @@ describe('IndexManagerService', () => {
|
||||
it('should create composite index successfully', async () => {
|
||||
mockQueryRunner.query.mockResolvedValue(undefined);
|
||||
|
||||
await service.createIndex('test_table', 'test_composite_index', ['column1', 'column2']);
|
||||
await service.createIndex('test_table', 'test_composite_index', [
|
||||
'column1',
|
||||
'column2',
|
||||
]);
|
||||
|
||||
expect(mockQueryRunner.query).toHaveBeenCalledWith(
|
||||
'CREATE INDEX test_composite_index ON test_table (column1, column2)',
|
||||
@@ -101,10 +104,14 @@ describe('IndexManagerService', () => {
|
||||
});
|
||||
|
||||
it('should handle index creation errors gracefully', async () => {
|
||||
mockQueryRunner.query.mockRejectedValue(new Error('Index creation failed'));
|
||||
mockQueryRunner.query.mockRejectedValue(
|
||||
new Error('Index creation failed'),
|
||||
);
|
||||
|
||||
// 应该不抛出异常,而是记录日志
|
||||
await expect(service.createIndex('test_table', 'test_index', ['column1'])).resolves.not.toThrow();
|
||||
await expect(
|
||||
service.createIndex('test_table', 'test_index', ['column1']),
|
||||
).resolves.not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -182,7 +189,9 @@ describe('IndexManagerService', () => {
|
||||
|
||||
expect(result).toEqual(mockStats);
|
||||
expect(mockQueryRunner.query).toHaveBeenCalledWith(
|
||||
expect.stringContaining('performance_schema.table_io_waits_summary_by_index_usage'),
|
||||
expect.stringContaining(
|
||||
'performance_schema.table_io_waits_summary_by_index_usage',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -200,8 +209,12 @@ describe('IndexManagerService', () => {
|
||||
// 模拟所有索引都不存在
|
||||
mockQueryRunner.query.mockResolvedValue([]);
|
||||
|
||||
const createIndexSpy = jest.spyOn(service, 'createIndex').mockResolvedValue(undefined);
|
||||
const checkIndexSpy = jest.spyOn(service, 'checkIndexExists').mockResolvedValue(false);
|
||||
const createIndexSpy = jest
|
||||
.spyOn(service, 'createIndex')
|
||||
.mockResolvedValue(undefined);
|
||||
const checkIndexSpy = jest
|
||||
.spyOn(service, 'checkIndexExists')
|
||||
.mockResolvedValue(false);
|
||||
|
||||
await service.checkAndCreateIndexes();
|
||||
|
||||
@@ -214,8 +227,12 @@ describe('IndexManagerService', () => {
|
||||
});
|
||||
|
||||
it('should skip creating existing indexes', async () => {
|
||||
const createIndexSpy = jest.spyOn(service, 'createIndex').mockResolvedValue(undefined);
|
||||
const checkIndexSpy = jest.spyOn(service, 'checkIndexExists').mockResolvedValue(true);
|
||||
const createIndexSpy = jest
|
||||
.spyOn(service, 'createIndex')
|
||||
.mockResolvedValue(undefined);
|
||||
const checkIndexSpy = jest
|
||||
.spyOn(service, 'checkIndexExists')
|
||||
.mockResolvedValue(true);
|
||||
|
||||
await service.checkAndCreateIndexes();
|
||||
|
||||
@@ -229,7 +246,9 @@ describe('IndexManagerService', () => {
|
||||
|
||||
describe('analyzeHotTables', () => {
|
||||
it('should analyze all hot tables', async () => {
|
||||
const analyzeTableSpy = jest.spyOn(service, 'analyzeTable').mockResolvedValue(undefined);
|
||||
const analyzeTableSpy = jest
|
||||
.spyOn(service, 'analyzeTable')
|
||||
.mockResolvedValue(undefined);
|
||||
|
||||
await service.analyzeHotTables();
|
||||
|
||||
@@ -242,4 +261,4 @@ describe('IndexManagerService', () => {
|
||||
analyzeTableSpy.mockRestore();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user