File tree Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Expand file tree Collapse file tree 3 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,8 @@ module.exports = {
4
4
testEnvironment : 'node' ,
5
5
testPathIgnorePatterns : [ '/node_modules/' , '/dist/' ] ,
6
6
} ;
7
+
8
+ process . env . ROS_REGION_ID = 'cn-hangzhou' ;
9
+ process . env . ALIYUN_ACCESS_KEY_ID = 'access key id' ;
10
+ process . env . ALIYUN_ACCESS_KEY_SECRET = 'access key secret' ;
11
+ process . env . ALIYUN_SECURITY_TOKEN = 'account id' ;
Original file line number Diff line number Diff line change 1
1
import { deploy } from '../../src/commands/deploy' ;
2
+ import { defaultContext } from '../fixtures/deployFixture' ;
2
3
3
4
const mockedDeployStack = jest . fn ( ) ;
4
5
jest . mock ( '../../src/stack' , ( ) => ( {
@@ -9,18 +10,10 @@ jest.mock('../../src/stack', () => ({
9
10
describe ( 'unit test for deploy command' , ( ) => {
10
11
it ( 'should construct valid context and deploy the stack when deploy with valid iac' , async ( ) => {
11
12
const stackName = 'my-demo-stack' ;
13
+
12
14
await deploy ( stackName , { location : 'tests/fixtures/serverless-insight.yml' , parameters : { } } ) ;
15
+
13
16
expect ( mockedDeployStack ) . toHaveBeenCalledTimes ( 1 ) ;
14
- expect ( mockedDeployStack ) . toHaveBeenCalledWith ( stackName , expect . any ( Object ) , {
15
- accessKeyId : undefined ,
16
- accessKeySecret : undefined ,
17
- iacLocation :
18
- '/Users/blank/Documents/dev/geekfun/serverlessinsight/tests/fixtures/serverless-insight.yml' ,
19
- parameters : [ ] ,
20
- region : 'cn-hangzhou' ,
21
- securityToken : undefined ,
22
- stackName : 'my-demo-stack' ,
23
- stage : 'default' ,
24
- } ) ;
17
+ expect ( mockedDeployStack ) . toHaveBeenCalledWith ( stackName , expect . any ( Object ) , defaultContext ) ;
25
18
} ) ;
26
19
} ) ;
Original file line number Diff line number Diff line change @@ -213,3 +213,14 @@ export const oneFcRos = {
213
213
} ,
214
214
} ,
215
215
} ;
216
+
217
+ export const defaultContext = {
218
+ accessKeyId : 'access key id' ,
219
+ accessKeySecret : 'access key secret' ,
220
+ iacLocation : expect . stringContaining ( 'tests/fixtures/serverless-insight.yml' ) ,
221
+ parameters : [ ] ,
222
+ region : 'cn-hangzhou' ,
223
+ securityToken : 'account id' ,
224
+ stackName : 'my-demo-stack' ,
225
+ stage : 'default' ,
226
+ } ;
You can’t perform that action at this time.
0 commit comments