1+ import { sleep } from '@ygkit/request' ;
12import { ApigwDeployInputs , ApigwDeployOutputs } from '../../src/modules/apigw/interface' ;
23import { Apigw } from '../../src' ;
34import { deepClone } from '../../src/utils' ;
@@ -7,6 +8,10 @@ describe('apigw app', () => {
78 SecretId : process . env . TENCENT_SECRET_ID ,
89 SecretKey : process . env . TENCENT_SECRET_KEY ,
910 } ;
11+ const appConfig = {
12+ name : 'serverless_app_test' ,
13+ description : 'Created by serverless test' ,
14+ } ;
1015 const inputs : ApigwDeployInputs = {
1116 protocols : [ 'http' , 'https' ] ,
1217 serviceName : 'serverless_test' ,
@@ -19,10 +24,7 @@ describe('apigw app', () => {
1924 method : 'POST' ,
2025 apiName : 'appauth' ,
2126 authType : 'APP' ,
22- app : {
23- name : 'serverless_app_test' ,
24- description : 'Created by serverless test' ,
25- } ,
27+ app : appConfig ,
2628 function : {
2729 functionName : 'serverless-unit-test' ,
2830 } ,
@@ -31,7 +33,7 @@ describe('apigw app', () => {
3133 } ;
3234 const apigw = new Apigw ( credentials , process . env . REGION ) ;
3335 let outputs : ApigwDeployOutputs ;
34-
36+ let appId : string = '' ;
3537 // 由于自定义域名必须 ICP 备案,所以这里测试域名不会通过,具体测试请使用
3638 test ( 'create apigw with app auth success' , async ( ) => {
3739 const apigwInputs = deepClone ( inputs ) ;
@@ -56,6 +58,7 @@ describe('apigw app', () => {
5658 } ,
5759 } ,
5860 ] ) ;
61+ appId = outputs . apiList [ 0 ] . app . id ;
5962 } ) ;
6063
6164 test ( 'update apigw without app auth success' , async ( ) => {
@@ -95,4 +98,24 @@ describe('apigw app', () => {
9598
9699 expect ( detail ) . toBeNull ( ) ;
97100 } ) ;
101+
102+ test ( 'get apigw app' , async ( ) => {
103+ const { app } = apigw . api ;
104+ const exist = await app . get ( appId ) ;
105+ expect ( exist ) . toEqual ( {
106+ id : appId ,
107+ name : appConfig . name ,
108+ description : expect . any ( String ) ,
109+ key : expect . any ( String ) ,
110+ secret : expect . any ( String ) ,
111+ } ) ;
112+ } ) ;
113+
114+ test ( 'delete apigw app' , async ( ) => {
115+ const { app } = apigw . api ;
116+ await app . delete ( appId ) ;
117+ await sleep ( 2000 ) ;
118+ const detail = await app . get ( appId ) ;
119+ expect ( detail ) . toEqual ( undefined ) ;
120+ } ) ;
98121} ) ;
0 commit comments