1
- #include < gtest/gtest.h>
2
1
#include < aws/core/client/ClientConfiguration.h>
3
2
#include < aws/core/utils/Outcome.h>
4
3
#include < aws/core/utils/memory/stl/AWSString.h>
12
11
#include < aws/lambda/model/CreateFunctionRequest.h>
13
12
#include < aws/lambda/model/DeleteFunctionRequest.h>
14
13
#include < aws/lambda/model/InvokeRequest.h>
14
+ #include " gtest/gtest.h"
15
+
16
+ extern std::string aws_prefix;
17
+
18
+ namespace {
15
19
16
20
using namespace Aws ::Lambda;
17
21
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" ;
20
24
21
25
struct LambdaRuntimeTest : public ::testing::Test {
22
26
LambdaClient m_lambda_client;
@@ -37,14 +41,19 @@ struct LambdaRuntimeTest : public ::testing::Test {
37
41
return config;
38
42
}
39
43
44
+ static Aws::String build_resource_name (Aws::String const & name)
45
+ {
46
+ return aws_prefix.c_str () + name; // NOLINT
47
+ }
48
+
40
49
LambdaRuntimeTest () : m_lambda_client(create_lambda_config()), m_iam_client(create_iam_config()) {}
41
50
42
51
~LambdaRuntimeTest () override
43
52
{
44
53
// 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*/ );
48
57
}
49
58
50
59
Aws::String get_role_arn (Aws::String const & role_name)
@@ -69,7 +78,7 @@ struct LambdaRuntimeTest : public ::testing::Test {
69
78
// I ran into eventual-consistency issues when creating the role dynamically as part of the test.
70
79
createFunctionRequest.SetRole (get_role_arn (" integration-tests" ));
71
80
Model::FunctionCode funcode;
72
- funcode.WithS3Bucket (S3BUCKET).WithS3Key (S3KEY);
81
+ funcode.WithS3Bucket (S3BUCKET).WithS3Key (build_resource_name ( S3KEY) );
73
82
createFunctionRequest.SetCode (funcode);
74
83
createFunctionRequest.SetRuntime (Aws::Lambda::Model::Runtime::provided);
75
84
@@ -90,7 +99,7 @@ struct LambdaRuntimeTest : public ::testing::Test {
90
99
91
100
TEST_F (LambdaRuntimeTest, echo_success)
92
101
{
93
- Aws::String const funcname = " echo_success" ;
102
+ Aws::String const funcname = build_resource_name ( " echo_success" ) ;
94
103
char const payloadContent[] = " Hello, Lambda!" ;
95
104
create_function (funcname);
96
105
Model::InvokeRequest invokeRequest;
@@ -121,7 +130,7 @@ TEST_F(LambdaRuntimeTest, echo_success)
121
130
122
131
TEST_F (LambdaRuntimeTest, echo_unicode)
123
132
{
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
125
134
char const payloadContent[] = " 画像は1000語の価値がある" ;
126
135
create_function (funcname);
127
136
Model::InvokeRequest invokeRequest;
@@ -152,7 +161,7 @@ TEST_F(LambdaRuntimeTest, echo_unicode)
152
161
153
162
TEST_F (LambdaRuntimeTest, echo_failure)
154
163
{
155
- Aws::String const funcname = " echo_failure" ;
164
+ Aws::String const funcname = build_resource_name ( " echo_failure" ) ;
156
165
create_function (funcname);
157
166
Model::InvokeRequest invokeRequest;
158
167
invokeRequest.SetFunctionName (funcname);
@@ -167,7 +176,7 @@ TEST_F(LambdaRuntimeTest, echo_failure)
167
176
168
177
TEST_F (LambdaRuntimeTest, binary_response)
169
178
{
170
- Aws::String const funcname = " binary_response" ;
179
+ Aws::String const funcname = build_resource_name ( " binary_response" ) ;
171
180
unsigned long constexpr expected_length = 1451 ;
172
181
create_function (funcname);
173
182
Model::InvokeRequest invokeRequest;
0 commit comments