Skip to content

Commit ba424b8

Browse files
committed
adding mock S3crt
1 parent 249a04b commit ba424b8

File tree

4 files changed

+72
-2
lines changed

4 files changed

+72
-2
lines changed

cmake/sdksCommon.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ list(APPEND SDK_TEST_PROJECT_LIST "rds:tests/aws-cpp-sdk-rds-integration-tests")
106106
list(APPEND SDK_TEST_PROJECT_LIST "redshift:tests/aws-cpp-sdk-redshift-integration-tests")
107107
list(APPEND SDK_TEST_PROJECT_LIST "s3:tests/aws-cpp-sdk-s3-integration-tests")
108108
list(APPEND SDK_TEST_PROJECT_LIST "s3:tests/aws-cpp-sdk-s3-unit-tests")
109-
list(APPEND SDK_TEST_PROJECT_LIST "s3-crt:tests/aws-cpp-sdk-s3-crt-integration-tests")
109+
list(APPEND SDK_TEST_PROJECT_LIST "s3-crt:tests/aws-cpp-sdk-s3-crt-integration-tests,tests/aws-cpp-sdk-s3-crt-unit-tests")
110110
list(APPEND SDK_TEST_PROJECT_LIST "s3-encryption:tests/aws-cpp-sdk-s3-encryption-tests,tests/aws-cpp-sdk-s3-encryption-integration-tests")
111111
list(APPEND SDK_TEST_PROJECT_LIST "s3control:tests/aws-cpp-sdk-s3control-integration-tests")
112112
list(APPEND SDK_TEST_PROJECT_LIST "sns:tests/aws-cpp-sdk-sns-integration-tests")

generated/src/aws-cpp-sdk-s3-crt/source/S3CrtClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ void S3CrtClient::S3CrtRequestFinishCallback(struct aws_s3_meta_request* meta_re
687687

688688
Aws::Client::XmlOutcome S3CrtClient::GenerateXmlOutcome(const std::shared_ptr<HttpResponse>& response) const {
689689
Aws::Client::HttpResponseOutcome httpOutcome;
690-
if (response->HasClientError() || AWSClient::DoesResponseGenerateError(response)) {
690+
if (AWSClient::DoesResponseGenerateError(response)) {
691691
AWS_LOGSTREAM_DEBUG(ALLOCATION_TAG, "Request returned error. Attempting to generate appropriate error codes from response");
692692
auto error = BuildAWSError(response);
693693
httpOutcome = HttpResponseOutcome(std::move(error));
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
add_project(aws-cpp-sdk-s3-crt-unit-tests
2+
"Unit Tests for the S3 crt SDK Client"
3+
aws-cpp-sdk-s3-crt
4+
testing-resources
5+
aws_test_main
6+
aws-cpp-sdk-core)
7+
8+
add_definitions(-DRESOURCES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/resources")
9+
10+
if(MSVC AND BUILD_SHARED_LIBS)
11+
add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1)
12+
endif()
13+
14+
enable_testing()
15+
16+
if(PLATFORM_ANDROID AND BUILD_SHARED_LIBS)
17+
add_library(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/S3crtUnitTests.cpp)
18+
else()
19+
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/S3crtUnitTests.cpp)
20+
endif()
21+
22+
set_compiler_flags(${PROJECT_NAME})
23+
set_compiler_warnings(${PROJECT_NAME})
24+
25+
target_link_libraries(${PROJECT_NAME} ${PROJECT_LIBS})
26+
27+
if(MSVC AND BUILD_SHARED_LIBS)
28+
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DELAYLOAD:aws-cpp-sdk-s3-crt.dll /DELAYLOAD:aws-cpp-sdk-core.dll")
29+
target_link_libraries(${PROJECT_NAME} delayimp.lib)
30+
endif()
31+
32+
include(GoogleTest)
33+
gtest_add_tests(TARGET ${PROJECT_NAME})
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <gtest/gtest.h>
2+
#include <aws/core/Aws.h>
3+
#include <aws/s3-crt/S3CrtClient.h>
4+
#include <aws/s3-crt/model/PutObjectRequest.h>
5+
#include <aws/core/http/standard/StandardHttpResponse.h>
6+
#include <aws/core/http/standard/StandardHttpRequest.h>
7+
#include <aws/core/utils/stream/PreallocatedStreamBuf.h>
8+
#include <aws/core/client/CoreErrors.h>
9+
#include <aws/core/client/AsyncCallerContext.h>
10+
#include <aws/core/utils/threading/Semaphore.h>
11+
#include <aws/common/error.h>
12+
#include <aws/s3/s3.h>
13+
#include <aws/testing/MemoryTesting.h>
14+
15+
using namespace Aws;
16+
using namespace Aws::S3Crt;
17+
using namespace Aws::S3Crt::Model;
18+
using namespace Aws::Client;
19+
20+
const char* ALLOCATION_TAG = "S3CrtTest";
21+
22+
23+
class TestS3CrtClient : public S3CrtClient {
24+
public:
25+
using S3CrtClient::S3CrtClient;
26+
};
27+
28+
class S3CrtUnitTest : public ::testing::Test
29+
{
30+
protected:
31+
void SetUp() override {}
32+
void TearDown() override {}
33+
};
34+
35+
TEST_F(S3CrtUnitTest, Test200WithErrorXml)
36+
{
37+
}

0 commit comments

Comments
 (0)