|
@@ -85,35 +85,4 @@ export function createTestServer(
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * 创建完整的测试应用实例
|
|
|
|
|
- */
|
|
|
|
|
-export async function createTestApp(routes: any[]) {
|
|
|
|
|
- const app = new OpenAPIHono();
|
|
|
|
|
-
|
|
|
|
|
- // 注册所有路由
|
|
|
|
|
- routes.forEach(route => {
|
|
|
|
|
- if (typeof route === 'function') {
|
|
|
|
|
- route(app);
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return app;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * 创建测试数据库连接
|
|
|
|
|
- */
|
|
|
|
|
-export async function createTestDataSource(): Promise<DataSource> {
|
|
|
|
|
- // 使用内存数据库或测试数据库
|
|
|
|
|
- const dataSource = new DataSource({
|
|
|
|
|
- type: 'better-sqlite3',
|
|
|
|
|
- database: ':memory:',
|
|
|
|
|
- synchronize: true,
|
|
|
|
|
- logging: false,
|
|
|
|
|
- entities: [], // 需要根据实际实体配置
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
- await dataSource.initialize();
|
|
|
|
|
- return dataSource;
|
|
|
|
|
-}
|
|
|