11'use strict' ;
22
33const HttpInvoke = require ( '../../lib/local/http-invoke' ) ;
4-
4+ const { ensureTmpDir } = require ( '../../lib/utils/path' ) ;
55const sinon = require ( 'sinon' ) ;
66const assert = sinon . assert ;
77
@@ -18,7 +18,7 @@ const httpx = require('httpx');
1818const FC = require ( '@alicloud/fc2' ) ;
1919
2020const { serviceName, serviceRes, functionName, functionRes,
21- httptriggerServiceRes , httpTriggerFunctionRes
21+ httpTriggerServiceRes , httpTriggerFunctionRes
2222} = require ( './mock-data' ) ;
2323
2424const { setProcess } = require ( '../test-utils' ) ;
@@ -106,8 +106,9 @@ describe('test http response', async () => {
106106 let server ;
107107 let restoreProcess ;
108108 let httpInvoke ;
109-
109+ let tmpDir ;
110110 beforeEach ( async ( ) => {
111+ tmpDir = await ensureTmpDir ( null , projectDir , serviceName , functionName ) ;
111112
112113 await fs . mkdirp ( projectDir ) ;
113114
@@ -147,18 +148,15 @@ def handler(environ, start_response):
147148 const endpointPrefix = `/2016-08-15/proxy/${ serviceName } /${ functionName } ` ;
148149 const endpoint = `${ endpointPrefix } *` ;
149150
150- httpInvoke = new HttpInvoke ( serviceName , httptriggerServiceRes ,
151- functionName , httpTriggerFunctionRes , null , null , projectDir , 'ANONYMOUS' , endpointPrefix ) ;
152-
151+ httpInvoke = new HttpInvoke ( serviceName , httpTriggerServiceRes ,
152+ functionName , httpTriggerFunctionRes , null , null , projectDir , tmpDir , 'ANONYMOUS' , endpointPrefix ) ;
153153 app . get ( endpoint , async ( req , res ) => {
154154 await httpInvoke . invoke ( req , res ) ;
155155 } ) ;
156-
157156 const resp = await httpx . request ( `http://localhost:${ serverPort } ${ endpointPrefix } ` , {
158157 method : 'GET' ,
159158 timeout : '3000'
160159 } ) ;
161-
162160 const body = await httpx . read ( resp , 'utf8' ) ;
163161
164162 expect ( body ) . to . contain ( 'Hello world!' ) ;
@@ -177,8 +175,8 @@ def handler(environ, start_response):
177175 const endpointPrefix = `/2016-08-15/proxy/${ serviceName } /${ functionName } ` ;
178176 const endpoint = `${ endpointPrefix } *` ;
179177
180- httpInvoke = new HttpInvoke ( serviceName , httptriggerServiceRes ,
181- functionName , httpTriggerFunctionRes , null , null , projectDir , 'FUNCTION' , endpointPrefix ) ;
178+ httpInvoke = new HttpInvoke ( serviceName , httpTriggerServiceRes ,
179+ functionName , httpTriggerFunctionRes , null , null , projectDir , tmpDir , 'FUNCTION' , endpointPrefix ) ;
182180
183181 app . get ( endpoint , async ( req , res ) => {
184182 await httpInvoke . invoke ( req , res ) ;
@@ -207,8 +205,8 @@ def handler(environ, start_response):
207205 const endpointPrefix = `/2016-08-15/proxy/${ serviceName } /${ functionName } ` ;
208206 const endpoint = `${ endpointPrefix } *` ;
209207
210- const httpInvoke = new HttpInvoke ( serviceName , httptriggerServiceRes ,
211- functionName , httpTriggerFunctionRes , null , null , projectDir , 'FUNCTION' , endpointPrefix ) ;
208+ const httpInvoke = new HttpInvoke ( serviceName , httpTriggerServiceRes ,
209+ functionName , httpTriggerFunctionRes , null , null , projectDir , tmpDir , 'FUNCTION' , endpointPrefix ) ;
212210
213211 app . get ( endpoint , async ( req , res ) => {
214212 await httpInvoke . invoke ( req , res ) ;
0 commit comments