1+ 'use strict' ; 
2+ 
3+ const  sinon  =  require ( 'sinon' ) ; 
4+ const  DeployFunction  =  require ( './deployFunction' ) ; 
5+ 
6+ describe ( 'DeployFunction@Library' ,  ( )  =>  { 
7+  let  deployFunction ; 
8+  let  deployFunctionStub ; 
9+  let  updateFunctionCodeStub ; 
10+  let  createFunctionStub ; 
11+  let  getFunctionStub ; 
12+  let  updateConfigurationStub ; 
13+  let  createTagsStub ; 
14+  let  uploadService2CosStub ; 
15+ 
16+  let  options ; 
17+ 
18+  beforeEach ( ( )  =>  { 
19+  options  =  { 
20+  region : 'ap-guangzhou' , 
21+  } ; 
22+  deployFunction  =  new  DeployFunction ( 'appid' ,  'secret_id' ,  'secret_key' ,  options ) ; 
23+ 
24+  deployFunctionStub  =  sinon . stub ( deployFunction ,  'deploy' ) 
25+  . returns ( Promise . resolve ( ) ) ; 
26+  updateFunctionCodeStub  =  sinon . stub ( deployFunction ,  'updateFunctionCode' ) 
27+  . returns ( Promise . resolve ( ) ) ; 
28+  createFunctionStub  =  sinon . stub ( deployFunction ,  'createFunction' ) 
29+  . returns ( Promise . resolve ( ) ) ; 
30+  getFunctionStub  =  sinon . stub ( deployFunction ,  'getFunction' ) 
31+  . returns ( Promise . resolve ( ) ) ; 
32+  updateConfigurationStub  =  sinon . stub ( deployFunction ,  'updateConfiguration' ) 
33+  . returns ( Promise . resolve ( ) ) ; 
34+  createTagsStub  =  sinon . stub ( deployFunction ,  'createTags' ) 
35+  . returns ( Promise . resolve ( ) ) ; 
36+  uploadService2CosStub  =  sinon . stub ( deployFunction ,  'uploadService2Cos' ) 
37+  . returns ( Promise . resolve ( ) ) ; 
38+ 
39+  } ) ; 
40+ 
41+  afterEach ( ( )  =>  { 
42+  deployFunction . deploy . restore ( ) ; 
43+  deployFunction . updateFunctionCode . restore ( ) ; 
44+  deployFunction . createFunction . restore ( ) ; 
45+  deployFunction . getFunction . restore ( ) ; 
46+  deployFunction . updateConfiguration . restore ( ) ; 
47+  deployFunction . createTags . restore ( ) ; 
48+  deployFunction . uploadService2Cos . restore ( ) ; 
49+  } ) ; 
50+ 
51+  it ( 'should make the deploy function accessible' ,  ( )  =>  { 
52+  deployFunction . should . to . be . an . instanceof ( DeployFunction ) ; 
53+  } ) ; 
54+ 
55+  it ( 'should run library deploy function' ,  ( )  =>  deployFunction 
56+  . deploy ( ) . then ( ( ) => { 
57+  deployFunctionStub . calledOnce . should . equal ( true ) 
58+  } ) ) ; 
59+ 
60+  it ( 'should run library update function code' ,  ( )  =>  deployFunction 
61+  . updateFunctionCode ( ) . then ( ( ) => { 
62+  updateFunctionCodeStub . calledOnce . should . equal ( true ) 
63+  } ) ) ; 
64+ 
65+  it ( 'should run library create function' ,  ( )  =>  deployFunction 
66+  . createFunction ( ) . then ( ( ) => { 
67+  createFunctionStub . calledOnce . should . equal ( true ) 
68+  } ) ) ; 
69+ 
70+  it ( 'should run library get function' ,  ( )  =>  deployFunction 
71+  . getFunction ( ) . then ( ( ) => { 
72+  getFunctionStub . calledOnce . should . equal ( true ) 
73+  } ) ) ; 
74+ 
75+  it ( 'should run library update configuration' ,  ( )  =>  deployFunction 
76+  . updateConfiguration ( ) . then ( ( ) => { 
77+  updateConfigurationStub . calledOnce . should . equal ( true ) 
78+  } ) ) ; 
79+ 
80+  it ( 'should run library create tags' ,  ( )  =>  deployFunction 
81+  . createTags ( ) . then ( ( ) => { 
82+  createTagsStub . calledOnce . should . equal ( true ) 
83+  } ) ) ; 
84+  it ( 'should run library upload service to cos' ,  ( )  =>  deployFunction 
85+  . uploadService2Cos ( ) . then ( ( ) => { 
86+  uploadService2CosStub . calledOnce . should . equal ( true ) 
87+  } ) ) ; 
88+ } ) ; 
0 commit comments