1- #include < gtest/gtest.h>
21#include < aws/core/client/ClientConfiguration.h>
32#include < aws/core/utils/Outcome.h>
43#include < aws/core/utils/memory/stl/AWSString.h>
1211#include < aws/lambda/model/CreateFunctionRequest.h>
1312#include < aws/lambda/model/DeleteFunctionRequest.h>
1413#include < aws/lambda/model/InvokeRequest.h>
14+ #include " gtest/gtest.h"
15+
16+ extern std::string aws_prefix;
17+
18+ namespace {
1519
1620using namespace Aws ::Lambda;
1721
18- static const char S3BUCKET[] = " aws-lambda-cpp-tests" ;
19- static const char S3KEY[] = " lambda-test-fun.zip" ;
22+ const char S3BUCKET[] = " aws-lambda-cpp-tests" ;
23+ const char S3KEY[] = " lambda-test-fun.zip" ;
2024
2125struct LambdaRuntimeTest : public ::testing::Test {
2226 LambdaClient m_lambda_client;
@@ -37,14 +41,19 @@ struct LambdaRuntimeTest : public ::testing::Test {
3741 return config;
3842 }
3943
44+ static Aws::String build_resource_name (Aws::String const & name)
45+ {
46+ return aws_prefix.c_str () + name; // NOLINT
47+ }
48+
4049 LambdaRuntimeTest () : m_lambda_client(create_lambda_config()), m_iam_client(create_iam_config()) {}
4150
4251 ~LambdaRuntimeTest () override
4352 {
4453 // clean up in case we exited one test abnormally
45- delete_function (" echo_success" , false /* assert*/ );
46- delete_function (" echo_failure" , false /* assert*/ );
47- delete_function (" binary_response" , false /* assert*/ );
54+ delete_function (build_resource_name ( " echo_success" ) , false /* assert*/ );
55+ delete_function (build_resource_name ( " echo_failure" ) , false /* assert*/ );
56+ delete_function (build_resource_name ( " binary_response" ) , false /* assert*/ );
4857 }
4958
5059 Aws::String get_role_arn (Aws::String const & role_name)
@@ -69,7 +78,7 @@ struct LambdaRuntimeTest : public ::testing::Test {
6978 // I ran into eventual-consistency issues when creating the role dynamically as part of the test.
7079 createFunctionRequest.SetRole (get_role_arn (" integration-tests" ));
7180 Model::FunctionCode funcode;
72- funcode.WithS3Bucket (S3BUCKET).WithS3Key (S3KEY);
81+ funcode.WithS3Bucket (S3BUCKET).WithS3Key (build_resource_name ( S3KEY) );
7382 createFunctionRequest.SetCode (funcode);
7483 createFunctionRequest.SetRuntime (Aws::Lambda::Model::Runtime::provided);
7584
@@ -90,7 +99,7 @@ struct LambdaRuntimeTest : public ::testing::Test {
9099
91100TEST_F (LambdaRuntimeTest, echo_success)
92101{
93- Aws::String const funcname = " echo_success" ;
102+ Aws::String const funcname = build_resource_name ( " echo_success" ) ;
94103 char const payloadContent[] = " Hello, Lambda!" ;
95104 create_function (funcname);
96105 Model::InvokeRequest invokeRequest;
@@ -121,7 +130,7 @@ TEST_F(LambdaRuntimeTest, echo_success)
121130
122131TEST_F (LambdaRuntimeTest, echo_unicode)
123132{
124- Aws::String const funcname = " echo_success" ; // re-use the echo method but with Unicode input
133+ Aws::String const funcname = build_resource_name ( " echo_success" ) ; // re-use the echo method but with Unicode input
125134 char const payloadContent[] = " 画像は1000語の価値がある" ;
126135 create_function (funcname);
127136 Model::InvokeRequest invokeRequest;
@@ -152,7 +161,7 @@ TEST_F(LambdaRuntimeTest, echo_unicode)
152161
153162TEST_F (LambdaRuntimeTest, echo_failure)
154163{
155- Aws::String const funcname = " echo_failure" ;
164+ Aws::String const funcname = build_resource_name ( " echo_failure" ) ;
156165 create_function (funcname);
157166 Model::InvokeRequest invokeRequest;
158167 invokeRequest.SetFunctionName (funcname);
@@ -167,7 +176,7 @@ TEST_F(LambdaRuntimeTest, echo_failure)
167176
168177TEST_F (LambdaRuntimeTest, binary_response)
169178{
170- Aws::String const funcname = " binary_response" ;
179+ Aws::String const funcname = build_resource_name ( " binary_response" ) ;
171180 unsigned long constexpr expected_length = 1451 ;
172181 create_function (funcname);
173182 Model::InvokeRequest invokeRequest;
0 commit comments