@@ -65,9 +65,9 @@ def run_command(self, cmd):
65
65
def sleep_1s (self ):
66
66
time .sleep (SLEEP_TIME )
67
67
68
- def invoke_function (self , json = {}, headers = {}):
68
+ def invoke_function (self , json = {}, headers = {}, function_name = "function" ):
69
69
return requests .post (
70
- f"http://localhost:{ self .PORT } /2015-03-31/functions/function /invocations" ,
70
+ f"http://localhost:{ self .PORT } /2015-03-31/functions/{ function_name } /invocations" ,
71
71
json = json ,
72
72
headers = headers ,
73
73
)
@@ -257,5 +257,25 @@ def test_custom_client_context(self):
257
257
self .assertEqual (123 , content ["baz" ])
258
258
259
259
260
+ def test_function_name_is_overriden_consistent (self ):
261
+ image , rie , image_name = self .tagged_name ("assert_overwritten_consistent" )
262
+
263
+ params = f"--name { image } -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName --env AWS_LAMBDA_RIE_DYNAMIC_FUNCTION_URL=TRUE -v { self .path_to_binary } :/local-lambda-runtime-server -p { self .PORT } :8080 --entrypoint /local-lambda-runtime-server/{ rie } { image_name } { DEFAULT_1P_ENTRYPOINT } main.assert_env_var_is_overwritten"
264
+
265
+ with self .create_container (params , image ):
266
+ r = self .invoke_function (function_name = "MyCoolName" )
267
+ self .assertEqual (b'"My lambda ran succesfully"' , r .content )
268
+
269
+
270
+ def test_lambda_function_arn_exists (self ):
271
+ image , rie , image_name = self .tagged_name ("arnexists_consistent" )
272
+
273
+ params = f"--name { image } -d --env AWS_LAMBDA_FUNCTION_NAME=MyCoolName --env AWS_LAMBDA_RIE_DYNAMIC_FUNCTION_URL=TRUE -v { self .path_to_binary } :/local-lambda-runtime-server -p { self .PORT } :8080 --entrypoint /local-lambda-runtime-server/{ rie } { image_name } { DEFAULT_1P_ENTRYPOINT } main.assert_lambda_arn_in_context"
274
+
275
+ with self .create_container (params , image ):
276
+ r = self .invoke_function (function_name = "MyCoolName" )
277
+ self .assertEqual (b'"My lambda ran succesfully"' , r .content )
278
+
279
+
260
280
if __name__ == "__main__" :
261
- main ()
281
+ main ()
0 commit comments