80 lines
2.8 KiB
C++
80 lines
2.8 KiB
C++
/*
|
|
Copyright <2018-2023> <scott.e.graves@protonmail.com>
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
*/
|
|
#if defined(REPERTORY_ENABLE_S3) && defined(REPERTORY_ENABLE_S3_TESTING)
|
|
|
|
#include "test_common.hpp"
|
|
|
|
#include "app_config.hpp"
|
|
#include "comm/curl/curl_comm.hpp"
|
|
#include "events/consumers/console_consumer.hpp"
|
|
#include "events/event_system.hpp"
|
|
#include "file_manager/file_manager.hpp"
|
|
#include "platform/platform.hpp"
|
|
#include "providers/s3/s3_provider.hpp"
|
|
#include "types/s3.hpp"
|
|
#include "types/startup_exception.hpp"
|
|
#include "utils/path_utils.hpp"
|
|
#include "utils/utils.hpp"
|
|
|
|
namespace repertory {
|
|
TEST(s3_provider, get_file_list) {
|
|
{
|
|
const auto config_path = utils::path::absolute("./s3_provider_test");
|
|
ASSERT_TRUE(utils::file::delete_directory_recursively(config_path));
|
|
|
|
console_consumer con{};
|
|
event_system::instance().start();
|
|
{
|
|
app_config cfg(provider_type::s3, config_path);
|
|
{
|
|
app_config src_cfg(provider_type::s3,
|
|
utils::path::combine(get_test_dir(), {"storj"}));
|
|
cfg.set_s3_config(src_cfg.get_s3_config());
|
|
}
|
|
|
|
curl_comm comm{cfg.get_s3_config()};
|
|
s3_provider provider{cfg, comm};
|
|
file_manager mgr(cfg, provider);
|
|
mgr.start();
|
|
|
|
EXPECT_TRUE(provider.start(
|
|
[&provider](bool directory, api_file &file) -> api_error {
|
|
return provider_meta_handler(provider, directory, file);
|
|
},
|
|
&mgr));
|
|
|
|
api_file_list list{};
|
|
EXPECT_EQ(api_error::success, provider.get_file_list(list));
|
|
provider.stop();
|
|
mgr.stop();
|
|
}
|
|
event_system::instance().stop();
|
|
|
|
ASSERT_TRUE(utils::file::delete_directory_recursively(config_path));
|
|
}
|
|
|
|
EXPECT_TRUE(utils::file::delete_directory_recursively("./s3_provider_test"));
|
|
}
|
|
} // namespace repertory
|
|
|
|
#endif // REPERTORY_ENABLE_S3_TESTING
|