forked from awsdocs/aws-doc-sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtest_put_object_async.cpp
More file actions
43 lines (35 loc) · 1.41 KB
/
gtest_put_object_async.cpp
File metadata and controls
43 lines (35 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/*
* Test types are indicated by the test label ending.
*
* _1_ Requires credentials, permissions, and AWS resources.
* _2_ Requires credentials and permissions.
* _3_ Does not require credentials.
*
*/
#include <gtest/gtest.h>
#include <fstream>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/PutObjectRequest.h>
#include "../s3_examples.h"
#include "S3_GTests.h"
static const int BUCKETS_NEEDED = 1;
namespace AwsDocTest {
// NOLINTNEXTLINE(readability-named-parameter)
TEST_F(S3_GTests, put_object_async_2_) {
std::vector<Aws::String> bucketNames = GetCachedS3Buckets(BUCKETS_NEEDED);
ASSERT_GE(bucketNames.size(), BUCKETS_NEEDED) << "Failed to meet precondition" << std::endl;
Aws::String testFile = GetTestFilePath();
ASSERT_TRUE(!testFile.empty()) << "Failed to meet precondition" << std::endl;
{
Aws::S3::S3Client client(*s_clientConfig);
Aws::S3::Model::PutObjectRequest request;
std::unique_lock<std::mutex> lock(AwsDoc::S3::upload_mutex);
bool result = AwsDoc::S3::uploadFileAsync(client, request, bucketNames[0], testFile);
AwsDoc::S3::upload_variable.wait(lock);
EXPECT_TRUE(result);
}
DeleteObjectInBucket(bucketNames[0], testFile);
}
} // namespace AwsDocTest