create-dp-koa 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/template/.cursor/commands/cheatsheet-backend-controller.md +45 -0
- package/template/.cursor/commands/implement-backend-api-controller.md +60 -0
- package/template/.cursor/commands/plan-backend.md +97 -0
- package/template/.cursor/rules/00-backend-core.skill.md +61 -0
- package/template/.cursor/rules/01-backend-skill-router.skill.md +57 -0
- package/template/.cursor/rules/10-backend-api.skill.md +55 -0
- package/template/.cursor/rules/11-backend-controller-recipes.skill.md +188 -0
- package/template/.cursor/rules/20-backend-repository.skill.md +25 -0
- package/template/.cursor/rules/21-backend-service.skill.md +137 -0
- package/template/.cursor/rules/25-backend-comments-and-doc.skill.md +98 -0
- package/template/.cursor/rules/30-backend-validation.skill.md +342 -0
- package/template/.cursor/rules/40-backend-error-logging.skill.md +21 -0
- package/template/.cursor/rules/50-backend-bootstrap-lifecycle.skill.md +105 -0
- package/template/.cursor/rules/60-backend-router-registration.skill.md +73 -0
- package/template/.cursor/rules/70-backend-middleware.skill.md +100 -0
- package/template/.cursor/rules/80-backend-utils-and-libs.skill.md +108 -0
- package/template/.cursor/rules/85-backend-plugins.rule.md +65 -0
- package/template/.cursor/rules/90-backend-testing.skill.md +29 -0
- package/template/.cursor/rules/README.md +49 -0
- package/template/.trae/skills/11-backend-controller-recipes.skill.md +91 -10
- package/template/scripts/sync-template.mjs +0 -1
- package/template/src/controllers/example/ExampleController.ts +14 -0
- package/template/src/entity/index.ts +1 -15
- package/template/src/framework/decorator/processor/AnnotationProcessor.ts +5 -1
- package/template/src/routers/index.ts +0 -35
- package/template/src/utils/testDataInitializer.ts +2 -269
- package/template/test/controllers/example/ExampleController.test.ts +29 -31
- package/template/test/framework/annotation/AnnotationDecorators.test.ts +15 -15
- package/template/test/framework/annotation/AnnotationExecutor.test.ts +27 -32
- package/template/test/framework/annotation/AnnotationProcessor.test.ts +25 -24
- package/template/test/framework/annotation/CustomProcessors.test.ts +15 -25
- package/template/test/framework/annotation/NewRouter.test.ts +9 -7
- package/template/test/framework/annotation/ProcessorManager.test.ts +14 -27
- package/template/test/framework/databaseConfig.test.ts +2 -2
- package/template/test/integration/integration.test.ts +15 -72
- package/template/src/controllers/cacheManagement.controller.ts +0 -131
- package/template/src/controllers/captcha.controller.ts +0 -57
- package/template/src/controllers/example/NewAnnotationExampleController.ts +0 -159
- package/template/src/controllers/example/SwaggerExampleController.ts +0 -205
- package/template/src/controllers/example/TransactionExample.controller.ts +0 -336
- package/template/src/controllers/health.controller.ts +0 -235
- package/template/src/controllers/home/register.controller.ts +0 -58
- package/template/src/controllers/home/ytGoods.controller.ts +0 -92
- package/template/src/controllers/home/ytShop.controller.ts +0 -135
- package/template/src/controllers/home/ytUser.controller.ts +0 -89
- package/template/src/controllers/logManagement.controller.ts +0 -396
- package/template/src/controllers/public/emailSend.controller.ts +0 -65
- package/template/src/controllers/public/ytUserAuth.controller.ts +0 -174
- package/template/src/controllers/testData.controller.ts +0 -253
- package/template/src/dto/controller/example/NewAnnotationExampleController.dto.ts +0 -73
- package/template/src/dto/controller/home/emailSend.controller.dto.ts +0 -40
- package/template/src/dto/controller/home/register.controller.dto.ts +0 -45
- package/template/src/dto/controller/home/ytGoods.controller.dto.ts +0 -55
- package/template/src/dto/controller/home/ytShop.controller.dto.ts +0 -69
- package/template/src/dto/controller/home/ytUser.controller.dto.ts +0 -44
- package/template/src/dto/controller/public/ytUserAuth.controller.dto.ts +0 -63
- package/template/src/dto/goods.dto.ts +0 -212
- package/template/src/dto/service/ytService.dto.ts +0 -13
- package/template/src/dto/user.dto.ts +0 -177
- package/template/src/entity/columnTypes.ts +0 -13
- package/template/src/entity/goodsImagesUnlockKey.entity.ts +0 -33
- package/template/src/entity/goodsUnlocker.entity.ts +0 -34
- package/template/src/entity/shop.entity.ts +0 -52
- package/template/src/entity/shopUser.entity.ts +0 -41
- package/template/src/entity/ytGoods.entity.ts +0 -94
- package/template/src/entity/ytUser.entity.ts +0 -96
- package/template/src/examples/SwaggerProcessorExample.ts +0 -169
- package/template/src/examples/TransactionManagerDemo.ts +0 -377
- package/template/src/framework/utils/dynamicSwagger.ts +0 -410
- package/template/src/repository/UserRepository.ts +0 -122
- package/template/src/service/paramValidateTest.service.ts +0 -139
- package/template/src/service/ytGoods.service.ts +0 -42
- package/template/src/service/ytShop.service.ts +0 -90
- package/template/src/service/ytUser.service.ts +0 -451
- package/template/src/test/swaggerParameterTest.ts +0 -90
- package/template/test/controllers/controllers.test.ts +0 -173
- package/template/test/controllers/example/NewAnnotationExampleController.test.ts +0 -200
- package/template/test/framework/TransactionManagerDemo.test.ts +0 -363
- package/template/test/service/business.test.ts +0 -87
- package/template/test/service/paramValidateTest.service.test.ts +0 -184
- package/template/test/service/ytUser.service.test.ts +0 -566
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { TestDatabaseHelper, TestUtils } from '../utils/testHelpers';
|
|
2
|
-
import { Provider } from 'dp-ioc2';
|
|
3
|
-
import { YtUserController } from '../../src/controllers/home/ytUser.controller';
|
|
4
|
-
import { YtShopController } from '../../src/controllers/home/ytShop.controller';
|
|
5
|
-
import { CaptchaController } from '../../src/controllers/captcha.controller';
|
|
6
|
-
|
|
7
|
-
describe('控制器测试', () => {
|
|
8
|
-
beforeAll(async () => {
|
|
9
|
-
await TestDatabaseHelper.initTestDatabase();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
afterAll(async () => {
|
|
13
|
-
await TestDatabaseHelper.cleanupTestDatabase();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
beforeEach(async () => {
|
|
17
|
-
await TestDatabaseHelper.resetTestData();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe('用户控制器测试', () => {
|
|
21
|
-
let userController: YtUserController;
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
userController = Provider<any>(YtUserController);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('应该能够获取用户信息', async () => {
|
|
28
|
-
const mockState = {
|
|
29
|
-
user: {
|
|
30
|
-
userId: 1,
|
|
31
|
-
type: 1
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const result = await userController.getUserInfo(mockState);
|
|
36
|
-
expect(result.code).toBe(0);
|
|
37
|
-
expect(result.data).toBeDefined();
|
|
38
|
-
expect(result.data?.id).toBe(1);
|
|
39
|
-
expect(result.data?.nickName).toBe('测试用户1');
|
|
40
|
-
expect(result.data?.email).toBe('test1@example.com');
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('应该返回失败当用户不存在时', async () => {
|
|
44
|
-
const mockState = {
|
|
45
|
-
user: {
|
|
46
|
-
userId: 999,
|
|
47
|
-
type: 1
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const result = await userController.getUserInfo(mockState);
|
|
52
|
-
expect(result.code).toBe(-1);
|
|
53
|
-
expect(result.data).toBeNull();
|
|
54
|
-
expect(result.message).toBe('用户不存在');
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test('应该能够检查用户是否有店铺', async () => {
|
|
58
|
-
const mockState = {
|
|
59
|
-
user: {
|
|
60
|
-
userId: 1,
|
|
61
|
-
type: 1
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const result = await userController.hasShop(mockState);
|
|
66
|
-
expect(result.code).toBe(0);
|
|
67
|
-
expect(result.data).toBeDefined();
|
|
68
|
-
expect(typeof result.data).toBe('number');
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('店铺控制器测试', () => {
|
|
73
|
-
let shopController: YtShopController;
|
|
74
|
-
|
|
75
|
-
beforeEach(() => {
|
|
76
|
-
shopController = Provider<any>(YtShopController);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
test('应该能够获取店铺信息', async () => {
|
|
80
|
-
const mockQuery = {
|
|
81
|
-
id: 1
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const result = await shopController.getShopInfoById(mockQuery);
|
|
85
|
-
expect(result.code).toBe(0);
|
|
86
|
-
expect(result.data).toBeDefined();
|
|
87
|
-
expect(result.data?.id).toBe(1);
|
|
88
|
-
expect(result.data?.name).toBe('测试店铺1');
|
|
89
|
-
expect(result.data?.userId).toBeDefined();
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('应该返回失败当店铺不存在时', async () => {
|
|
93
|
-
const mockQuery = {
|
|
94
|
-
id: 999
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const result = await shopController.getShopInfoById(mockQuery);
|
|
98
|
-
expect(result.code).toBe(-1);
|
|
99
|
-
expect(result.data).toBeNull();
|
|
100
|
-
expect(result.message).toBe('店铺不存在');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('应该能够获取店铺商品列表', async () => {
|
|
104
|
-
const mockQuery = {
|
|
105
|
-
id: 1,
|
|
106
|
-
page: 1,
|
|
107
|
-
pageSize: 10
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const result = await shopController.getShopGoodsList(mockQuery);
|
|
111
|
-
expect(result.code).toBe(0);
|
|
112
|
-
expect(result.data).toBeDefined();
|
|
113
|
-
expect(Array.isArray(result.data?.[0])).toBe(true);
|
|
114
|
-
expect(typeof result.data?.[1]).toBe('number');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('应该能够获取店铺用户信息', async () => {
|
|
118
|
-
const mockQuery = {
|
|
119
|
-
shopId: 1
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const result = await shopController.getShopUserInfo(mockQuery);
|
|
123
|
-
expect(result.code).toBe(0);
|
|
124
|
-
expect(result.data).toBeDefined();
|
|
125
|
-
expect(result.data?.id).toBeDefined();
|
|
126
|
-
expect(result.data?.nickName).toBeDefined();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe('验证码控制器测试', () => {
|
|
131
|
-
let captchaController: CaptchaController;
|
|
132
|
-
|
|
133
|
-
beforeEach(() => {
|
|
134
|
-
captchaController = Provider<any>(CaptchaController);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
test('应该能够生成验证码', async () => {
|
|
138
|
-
const result = await captchaController.getCaptcha();
|
|
139
|
-
expect(result).toBeDefined();
|
|
140
|
-
expect(result.image).toBeDefined();
|
|
141
|
-
expect(result.token).toBeDefined();
|
|
142
|
-
expect(result.contentType).toBe('image/svg+xml');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('应该能够验证正确的验证码', async () => {
|
|
146
|
-
// 先生成验证码
|
|
147
|
-
const captchaResult = await captchaController.getCaptcha();
|
|
148
|
-
const { token } = captchaResult;
|
|
149
|
-
|
|
150
|
-
// 模拟用户输入(这里需要知道正确的验证码,实际测试中可能需要mock)
|
|
151
|
-
const mockBody = {
|
|
152
|
-
captcha: 'test', // 这里应该是正确的验证码
|
|
153
|
-
token: token
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
const result = await captchaController.verifyCaptcha(mockBody);
|
|
157
|
-
expect(result).toBeDefined();
|
|
158
|
-
expect(typeof result.success).toBe('boolean');
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('应该拒绝缺少token的验证请求', async () => {
|
|
162
|
-
const mockBody = {
|
|
163
|
-
captcha: 'test',
|
|
164
|
-
token: ''
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const result = await captchaController.verifyCaptcha(mockBody);
|
|
168
|
-
expect(result.status).toBe(400);
|
|
169
|
-
expect(result.body?.success).toBe(false);
|
|
170
|
-
expect(result.body?.message).toBe('Missing captcha token');
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
});
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { NewAnnotationExampleController } from '../../../src/controllers/example/NewAnnotationExampleController';
|
|
2
|
-
import { MigrationHelper } from '../../../src/framework/utils/MigrationHelper';
|
|
3
|
-
import { ProcessorManager } from '../../../src/framework/decorator/processor/ProcessorManager';
|
|
4
|
-
import { TestDatabaseHelper, TestUtils } from '../../utils/testHelpers';
|
|
5
|
-
|
|
6
|
-
describe('新注解系统集成测试', () => {
|
|
7
|
-
let controller: NewAnnotationExampleController;
|
|
8
|
-
|
|
9
|
-
beforeAll(async () => {
|
|
10
|
-
// 初始化测试数据库
|
|
11
|
-
await TestDatabaseHelper.initTestDatabase();
|
|
12
|
-
|
|
13
|
-
// 启用新注解系统
|
|
14
|
-
MigrationHelper.enableNewSystem();
|
|
15
|
-
|
|
16
|
-
// 创建控制器实例
|
|
17
|
-
controller = new NewAnnotationExampleController();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
afterAll(async () => {
|
|
21
|
-
// 清理测试数据库
|
|
22
|
-
await TestDatabaseHelper.closeTestDatabase();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
beforeEach(async () => {
|
|
26
|
-
// 重置测试数据
|
|
27
|
-
await TestDatabaseHelper.resetTestData();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('系统状态检查', () => {
|
|
31
|
-
test('应该正确初始化新注解系统', () => {
|
|
32
|
-
const status = MigrationHelper.getSystemStatus();
|
|
33
|
-
expect(status.newSystemEnabled).toBe(true);
|
|
34
|
-
expect(status.newSystemInitialized).toBe(true);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('应该能够检测控制器注解类型', () => {
|
|
38
|
-
const isNew = MigrationHelper.isUsingNewAnnotationSystem(controller);
|
|
39
|
-
const isLegacy = MigrationHelper.isUsingLegacyAnnotationSystem(controller);
|
|
40
|
-
|
|
41
|
-
expect(isNew).toBe(true);
|
|
42
|
-
expect(isLegacy).toBe(true); // 因为使用了混合注解
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('应该能够检查控制器兼容性', () => {
|
|
46
|
-
const compatibility = MigrationHelper.checkControllerCompatibility(controller);
|
|
47
|
-
expect(compatibility.compatible).toBe(true);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('基础功能测试', () => {
|
|
52
|
-
test('应该能够执行基础示例方法', async () => {
|
|
53
|
-
const mockQuery = { id: '123', name: 'test' };
|
|
54
|
-
const mockContext = TestUtils.createMockContext({}, mockQuery);
|
|
55
|
-
|
|
56
|
-
const result = await controller.basicExample(mockQuery);
|
|
57
|
-
|
|
58
|
-
expect(result.code).toBe(0);
|
|
59
|
-
expect(result.data).toBe('基础示例执行成功');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('应该能够处理权限检查', async () => {
|
|
63
|
-
const mockUser = {
|
|
64
|
-
id: 1,
|
|
65
|
-
name: 'test',
|
|
66
|
-
permissions: ['read:sensitive-data']
|
|
67
|
-
};
|
|
68
|
-
const mockState = { user: mockUser };
|
|
69
|
-
|
|
70
|
-
const result = await controller.getProtectedData(mockUser);
|
|
71
|
-
|
|
72
|
-
expect(result.code).toBe(0);
|
|
73
|
-
expect(result.data.message).toBe('这是受保护的数据');
|
|
74
|
-
expect(result.data.user).toEqual(mockUser);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('应该能够处理限流', async () => {
|
|
78
|
-
const mockBody = { name: 'test', value: 'example' };
|
|
79
|
-
|
|
80
|
-
// 第一次请求应该成功
|
|
81
|
-
const result1 = await controller.rateLimitedEndpoint(mockBody);
|
|
82
|
-
expect(result1.code).toBe(0);
|
|
83
|
-
|
|
84
|
-
// 连续请求应该成功(在测试环境中限流可能不会生效)
|
|
85
|
-
const result2 = await controller.rateLimitedEndpoint(mockBody);
|
|
86
|
-
expect(result2.code).toBe(0);
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
describe('复合注解测试', () => {
|
|
91
|
-
test('应该能够处理复合注解', async () => {
|
|
92
|
-
const mockQuery = { id: '456', category: 'test' };
|
|
93
|
-
const mockUser = {
|
|
94
|
-
id: 1,
|
|
95
|
-
name: 'test',
|
|
96
|
-
permissions: ['read:complex-data']
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const result = await controller.complexExample(mockQuery, mockUser);
|
|
100
|
-
|
|
101
|
-
expect(result.code).toBe(0);
|
|
102
|
-
expect(result.data.message).toBe('复杂示例执行成功');
|
|
103
|
-
expect(result.data.query).toEqual(mockQuery);
|
|
104
|
-
expect(result.data.user).toEqual(mockUser);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test('应该能够处理混合注解', async () => {
|
|
108
|
-
const mockBody = { name: 'mixed', value: 'example' };
|
|
109
|
-
|
|
110
|
-
const result = await controller.mixedAnnotations(mockBody);
|
|
111
|
-
|
|
112
|
-
expect(result.code).toBe(0);
|
|
113
|
-
expect(result.data.message).toBe('混合注解示例执行成功');
|
|
114
|
-
expect(result.data.note).toBe('这个端点同时使用了新旧注解系统');
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
describe('错误处理测试', () => {
|
|
119
|
-
test('应该能够处理权限不足错误', async () => {
|
|
120
|
-
await expect(controller.errorExample()).rejects.toThrow('模拟权限不足错误');
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe('异步处理测试', () => {
|
|
125
|
-
test('应该能够处理异步方法', async () => {
|
|
126
|
-
const startTime = Date.now();
|
|
127
|
-
const result = await controller.asyncExample();
|
|
128
|
-
const endTime = Date.now();
|
|
129
|
-
|
|
130
|
-
expect(result.code).toBe(0);
|
|
131
|
-
expect(result.data.message).toBe('异步处理完成');
|
|
132
|
-
expect(endTime - startTime).toBeGreaterThanOrEqual(1000); // 至少1秒
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe('数据验证测试', () => {
|
|
137
|
-
test('应该能够处理数据验证', async () => {
|
|
138
|
-
const mockBody = { name: 'validation', value: 'test' };
|
|
139
|
-
|
|
140
|
-
const result = await controller.validationExample(mockBody);
|
|
141
|
-
|
|
142
|
-
expect(result.code).toBe(0);
|
|
143
|
-
expect(result.data.message).toBe('验证通过');
|
|
144
|
-
expect(result.data.receivedData).toEqual(mockBody);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe('系统切换测试', () => {
|
|
149
|
-
test('应该能够切换注解系统', () => {
|
|
150
|
-
// 当前应该是新系统
|
|
151
|
-
expect(MigrationHelper.getCurrentSystem()).toBe('new');
|
|
152
|
-
|
|
153
|
-
// 切换到旧系统
|
|
154
|
-
MigrationHelper.disableNewSystem();
|
|
155
|
-
expect(MigrationHelper.getCurrentSystem()).toBe('legacy');
|
|
156
|
-
|
|
157
|
-
// 切换回新系统
|
|
158
|
-
MigrationHelper.enableNewSystem();
|
|
159
|
-
expect(MigrationHelper.getCurrentSystem()).toBe('new');
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
test('应该能够切换系统状态', () => {
|
|
163
|
-
const initialState = MigrationHelper.getCurrentSystem();
|
|
164
|
-
|
|
165
|
-
// 切换系统
|
|
166
|
-
const newState = MigrationHelper.toggleSystem();
|
|
167
|
-
|
|
168
|
-
if (initialState === 'new') {
|
|
169
|
-
expect(newState).toBe(false);
|
|
170
|
-
expect(MigrationHelper.getCurrentSystem()).toBe('legacy');
|
|
171
|
-
} else {
|
|
172
|
-
expect(newState).toBe(true);
|
|
173
|
-
expect(MigrationHelper.getCurrentSystem()).toBe('new');
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('性能测试', () => {
|
|
179
|
-
test('应该能够处理大量请求', async () => {
|
|
180
|
-
const mockQuery = { id: 'perf', name: 'test' };
|
|
181
|
-
const startTime = Date.now();
|
|
182
|
-
|
|
183
|
-
// 执行100次请求
|
|
184
|
-
const promises = Array(100).fill(null).map(() =>
|
|
185
|
-
controller.basicExample(mockQuery)
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
const results = await Promise.all(promises);
|
|
189
|
-
const endTime = Date.now();
|
|
190
|
-
|
|
191
|
-
// 验证所有请求都成功
|
|
192
|
-
results.forEach(result => {
|
|
193
|
-
expect(result.code).toBe(0);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
// 验证性能(100次请求应该在合理时间内完成)
|
|
197
|
-
expect(endTime - startTime).toBeLessThan(5000); // 5秒内完成
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
});
|