1
+ import { sleep } from '@ygkit/request' ;
1
2
import { ApigwDeployInputs , ApigwDeployOutputs } from '../../src/modules/apigw/interface' ;
2
3
import { Apigw } from '../../src' ;
3
4
import { deepClone } from '../../src/utils' ;
@@ -7,6 +8,10 @@ describe('apigw app', () => {
7
8
SecretId : process . env . TENCENT_SECRET_ID ,
8
9
SecretKey : process . env . TENCENT_SECRET_KEY ,
9
10
} ;
11
+ const appConfig = {
12
+ name : 'serverless_app_test' ,
13
+ description : 'Created by serverless test' ,
14
+ } ;
10
15
const inputs : ApigwDeployInputs = {
11
16
protocols : [ 'http' , 'https' ] ,
12
17
serviceName : 'serverless_test' ,
@@ -19,10 +24,7 @@ describe('apigw app', () => {
19
24
method : 'POST' ,
20
25
apiName : 'appauth' ,
21
26
authType : 'APP' ,
22
- app : {
23
- name : 'serverless_app_test' ,
24
- description : 'Created by serverless test' ,
25
- } ,
27
+ app : appConfig ,
26
28
function : {
27
29
functionName : 'serverless-unit-test' ,
28
30
} ,
@@ -31,7 +33,7 @@ describe('apigw app', () => {
31
33
} ;
32
34
const apigw = new Apigw ( credentials , process . env . REGION ) ;
33
35
let outputs : ApigwDeployOutputs ;
34
-
36
+ let appId : string = '' ;
35
37
// 由于自定义域名必须 ICP 备案,所以这里测试域名不会通过,具体测试请使用
36
38
test ( 'create apigw with app auth success' , async ( ) => {
37
39
const apigwInputs = deepClone ( inputs ) ;
@@ -56,6 +58,7 @@ describe('apigw app', () => {
56
58
} ,
57
59
} ,
58
60
] ) ;
61
+ appId = outputs . apiList [ 0 ] . app . id ;
59
62
} ) ;
60
63
61
64
test ( 'update apigw without app auth success' , async ( ) => {
@@ -95,4 +98,24 @@ describe('apigw app', () => {
95
98
96
99
expect ( detail ) . toBeNull ( ) ;
97
100
} ) ;
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
+ } ) ;
98
121
} ) ;
0 commit comments