@@ -31,15 +31,20 @@ describe("e2e: quota", () => {
3131 expect ( stderr ) . toContain ( "--model" ) ;
3232 expect ( stderr ) . toContain ( "--rpm" ) ;
3333 expect ( stderr ) . toContain ( "--tpm" ) ;
34- expect ( stderr ) . toContain ( "--delete" ) ;
34+ } ) ;
35+
36+ test ( "quota delete --help 正常退出" , async ( ) => {
37+ const { stderr, exitCode } = await runCommandHelp ( QUOTA_ROUTES , [ "quota" , "delete" , "--help" ] ) ;
38+ expect ( exitCode , stderr ) . toBe ( 0 ) ;
39+ expect ( stderr ) . toContain ( "--model" ) ;
3540 expect ( stderr ) . toContain ( "--yes" ) ;
41+ expect ( stderr ) . toContain ( "bl quota delete --model qwen-plus" ) ;
3642 } ) ;
3743
3844 test ( "quota request 作为 quota update 的兼容别名可用" , async ( ) => {
3945 const { stderr, exitCode } = await runCommandHelp ( QUOTA_ROUTES , [ "quota" , "request" , "--help" ] ) ;
4046 expect ( exitCode , stderr ) . toBe ( 0 ) ;
4147 expect ( stderr ) . toContain ( "--rpm" ) ;
42- expect ( stderr ) . toContain ( "--delete" ) ;
4348 } ) ;
4449
4550 test ( "quota history --help 正常退出" , async ( ) => {
@@ -68,36 +73,41 @@ describe("e2e: quota", () => {
6873 expect ( stderr ) . toContain ( "at least 1 minute" ) ;
6974 } ) ;
7075
71- test ( "quota update 缺少 --rpm/--tpm/--delete 报用法错误" , async ( ) => {
76+ test ( "quota update 缺少 --rpm/--tpm 报用法错误" , async ( ) => {
7277 const { stderr, exitCode } = await runCommandE2e ( QUOTA_ROUTES , [
7378 "quota" ,
7479 "update" ,
7580 "--model" ,
7681 "qwen-plus" ,
7782 ] ) ;
7883 expect ( exitCode ) . toBe ( 2 ) ;
79- expect ( stderr ) . toContain ( "one of --rpm / --tpm / --delete " ) ;
84+ expect ( stderr ) . toContain ( "one of --rpm / --tpm" ) ;
8085 } ) ;
8186
82- test ( "quota update --delete 与 --rpm 互斥 " , async ( ) => {
87+ test ( "quota update 不再接受 --delete " , async ( ) => {
8388 const { stderr, exitCode } = await runCommandE2e ( QUOTA_ROUTES , [
8489 "quota" ,
8590 "update" ,
8691 "--model" ,
8792 "qwen-plus" ,
8893 "--delete" ,
89- "--rpm" ,
90- "60" ,
9194 ] ) ;
9295 expect ( exitCode ) . toBe ( 2 ) ;
93- expect ( stderr ) . toContain ( "cannot be combined " ) ;
96+ expect ( stderr ) . toContain ( "Unknown flag " ) ;
9497 } ) ;
9598
96- test ( "quota update --delete 非 TTY 无 --yes 报 USAGE (2)" , async ( ) => {
99+ test ( "quota delete 缺少 --model 报用法错误" , async ( ) => {
100+ // 裸 `quota delete`(无任何 flag)会渲染 help 并正常退出,需带 flag 触发必填校验
101+ const { stderr, exitCode } = await runCommandE2e ( QUOTA_ROUTES , [ "quota" , "delete" , "--yes" ] ) ;
102+ expect ( exitCode ) . toBe ( 2 ) ;
103+ expect ( stderr ) . toContain ( "Missing required flag: --model" ) ;
104+ } ) ;
105+
106+ test ( "quota delete 非 TTY 无 --yes 报 USAGE (2)" , async ( ) => {
97107 // 注入假 key 让 apiKey 鉴权通过;确认门在发任何网络请求前触发
98108 const { stderr, exitCode } = await runCommandE2e (
99109 QUOTA_ROUTES ,
100- [ "quota" , "update " , "--model" , "qwen-plus" , "--delete "] ,
110+ [ "quota" , "delete " , "--model" , "qwen-plus" ] ,
101111 { DASHSCOPE_API_KEY : "sk-e2e-quota-delete" } ,
102112 ) ;
103113 expect ( exitCode ) . toBe ( 2 ) ;
@@ -196,13 +206,12 @@ describe("e2e: quota", () => {
196206 expect ( entry ?. usage_limit_period ) . toBe ( 60 ) ;
197207 } ) ;
198208
199- test ( "quota update -- delete --dry-run 输出 DELETE 操作" , async ( ) => {
209+ test ( "quota delete --dry-run 输出 DELETE 操作" , async ( ) => {
200210 const { stdout, stderr, exitCode } = await runCommandE2e ( QUOTA_ROUTES , [
201211 "quota" ,
202- "update " ,
212+ "delete " ,
203213 "--model" ,
204214 "qwen-plus" ,
205- "--delete" ,
206215 "--dry-run" ,
207216 "--output" ,
208217 "json" ,
@@ -211,6 +220,7 @@ describe("e2e: quota", () => {
211220 const data = parseStdoutJson < {
212221 request ?: { models ?: { model ?: string ; operation_type ?: string } [ ] } ;
213222 } > ( stdout ) ;
223+ expect ( data . request ?. models ?. [ 0 ] ?. model ) . toBe ( "qwen-plus" ) ;
214224 expect ( data . request ?. models ?. [ 0 ] ?. operation_type ) . toBe ( "DELETE" ) ;
215225 } ) ;
216226
@@ -285,8 +295,8 @@ describe("e2e: quota", () => {
285295 } ) ;
286296} ) ;
287297
288- // 真实调用 GET /api/v1/models/limits。quota update 只测 --dry-run——live POST
289- // 会真实改写账号限流,不做 e2e。
298+ // 真实调用 GET /api/v1/models/limits。quota update / quota delete 只测
299+ // --dry-run——live POST 会真实改写账号限流,不做 e2e。
290300describe . skipIf ( ! isDashScopeE2EReady ( ) ) ( "e2e: quota(DashScope)" , ( ) => {
291301 test ( "quota list 文本输出正常退出" , async ( ) => {
292302 const { stderr, exitCode } = await runCommandE2e ( QUOTA_ROUTES , [
0 commit comments