| 133 | }; |
| 134 | |
| 135 | TEST_F(LambdaRuntimeTest, echo_success) |
| 136 | { |
| 137 | Aws::String const funcname = build_resource_name("echo_success"); |
| 138 | constexpr auto payload_content = "Hello, Lambda!"; |
| 139 | create_function(funcname, "echo_success" /*handler_name*/); |
| 140 | Model::InvokeRequest invoke_request; |
| 141 | invoke_request.SetFunctionName(funcname); |
| 142 | invoke_request.SetInvocationType(Model::InvocationType::RequestResponse); |
| 143 | invoke_request.SetContentType("application/json"); |
| 144 | |
| 145 | std::shared_ptr<Aws::IOStream> payload = Aws::MakeShared<Aws::StringStream>("FunctionTest"); |
| 146 | Aws::Utils::Json::JsonValue json_payload; |
| 147 | json_payload.WithString("barbaz", payload_content); |
| 148 | *payload << json_payload.View().WriteCompact(); |
| 149 | invoke_request.SetBody(payload); |
| 150 | |
| 151 | Model::InvokeOutcome invoke_outcome = m_lambda_client.Invoke(invoke_request); |
| 152 | EXPECT_TRUE(invoke_outcome.IsSuccess()); |
| 153 | Aws::StringStream output; |
| 154 | if (!invoke_outcome.IsSuccess()) { |
| 155 | delete_function(funcname); |
| 156 | return; |
| 157 | } |
| 158 | EXPECT_EQ(200, invoke_outcome.GetResult().GetStatusCode()); |
| 159 | EXPECT_TRUE(invoke_outcome.GetResult().GetFunctionError().empty()); |
| 160 | auto const json_response = Aws::Utils::Json::JsonValue(invoke_outcome.GetResult().GetPayload()); |
| 161 | EXPECT_TRUE(json_response.WasParseSuccessful()); |
| 162 | EXPECT_STREQ(payload_content, json_response.View().GetString("barbaz").c_str()); |
| 163 | delete_function(funcname); |
| 164 | } |
| 165 | |
| 166 | TEST_F(LambdaRuntimeTest, echo_unicode) |
| 167 | { |