Browse Source

📝 docs(test): 添加测试工具函数注释说明

- 为createIntegrationTestApp函数添加注释,说明使用主API应用确保所有路由已注册

♻️ refactor(test): 移除重复的测试工具函数

- 删除createTestApp函数,避免与现有测试应用创建逻辑重复
- 删除createTestDataSource函数,精简测试工具集
yourname 2 tháng trước cách đây
mục cha
commit
929226de6b

+ 1 - 1
src/server/__test_utils__/integration-test-utils.ts

@@ -31,7 +31,7 @@ export async function createIntegrationTestApp(
   routes: any[],
   options: IntegrationTestOptions = {}
 ): Promise<OpenAPIHono> {
-  // 使用主API应用
+  // 使用主API应用,确保所有路由已注册
   return apiApp;
 }
 

+ 0 - 31
src/server/__test_utils__/test-server.ts

@@ -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;
-}