continue refactor drive tests
This commit is contained in:
parent
5138b0d1ab
commit
b6456abf0d
@ -24,62 +24,6 @@
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
|
||||
namespace repertory {
|
||||
// static void rename_file_test(winfsp_test *test,
|
||||
// const std::string &mount_point) {
|
||||
// TEST_HEADER(__FUNCTION__);
|
||||
// const auto file = utils::path::combine(mount_point, {"rename_file.txt"});
|
||||
// auto handle = ::CreateFileA(&file[0], GENERIC_READ, FILE_SHARE_READ,
|
||||
// nullptr,
|
||||
// CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
// EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
// EXPECT_TRUE(::CloseHandle(handle));
|
||||
//
|
||||
// api_meta_map meta1{};
|
||||
// EXPECT_EQ(api_error::success,
|
||||
// test->provider->get_item_meta("/rename_file.txt", meta1));
|
||||
//
|
||||
// const auto file2 = utils::path::combine(mount_point, {"rename_file2.txt"});
|
||||
// EXPECT_TRUE(::MoveFile(&file[0], &file2[0]));
|
||||
//
|
||||
// EXPECT_TRUE(utils::file::file(file2).exists());
|
||||
// EXPECT_FALSE(utils::file::file(file).exists());
|
||||
//
|
||||
// api_meta_map meta2{};
|
||||
// EXPECT_EQ(api_error::success,
|
||||
// test->provider->get_item_meta("/rename_file2.txt", meta2));
|
||||
// EXPECT_STREQ(meta1[META_SOURCE].c_str(), meta2[META_SOURCE].c_str());
|
||||
//
|
||||
// filesystem_item fsi{};
|
||||
// EXPECT_EQ(api_error::success, test->provider->get_filesystem_item(
|
||||
// "/rename_file2.txt", false, fsi));
|
||||
// EXPECT_STREQ(meta1[META_SOURCE].c_str(), fsi.source_path.c_str());
|
||||
//
|
||||
// filesystem_item fsi2{};
|
||||
// EXPECT_EQ(api_error::success,
|
||||
// test->provider->get_filesystem_item_from_source_path(
|
||||
// fsi.source_path, fsi2));
|
||||
// EXPECT_STREQ("/rename_file2.txt", fsi2.api_path.c_str());
|
||||
//
|
||||
// EXPECT_EQ(api_error::item_not_found,
|
||||
// test->provider->get_item_meta("/rename_file.txt", meta2));
|
||||
// }
|
||||
//
|
||||
// static void rename_directory_test(const std::string &mount_point) {
|
||||
// TEST_HEADER(__FUNCTION__);
|
||||
// std::string directory = "rename_dir";
|
||||
// const auto full_directory = utils::path::combine(mount_point, {directory});
|
||||
// std::string directory2 = "rename_dir2";
|
||||
// const auto full_directory2 = utils::path::combine(mount_point,
|
||||
// {directory2});
|
||||
//
|
||||
// EXPECT_FALSE(::PathIsDirectory(&full_directory[0]));
|
||||
// EXPECT_TRUE(::CreateDirectoryA(&full_directory[0], nullptr));
|
||||
// EXPECT_TRUE(::PathIsDirectory(&full_directory[0]));
|
||||
// EXPECT_TRUE(::MoveFile(&full_directory[0], &full_directory2[0]));
|
||||
// EXPECT_FALSE(::PathIsDirectory(&full_directory[0]));
|
||||
// EXPECT_TRUE(::PathIsDirectory(&full_directory2[0]));
|
||||
// }
|
||||
//
|
||||
// static void get_set_basic_info_test(const std::string &mount_point) {
|
||||
// TEST_HEADER(__FUNCTION__);
|
||||
//
|
||||
@ -139,32 +83,6 @@ namespace repertory {
|
||||
// EXPECT_TRUE(::CloseHandle(handle));
|
||||
// }
|
||||
//
|
||||
// static void overwrite_file_test(const std::string &mount_point) {
|
||||
// TEST_HEADER(__FUNCTION__);
|
||||
//
|
||||
// const auto file = utils::path::combine("./", {"test_overwrite.txt"});
|
||||
// auto handle =
|
||||
// ::CreateFileA(&file[0], GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,
|
||||
// nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
// EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
// if (handle != INVALID_HANDLE_VALUE) {
|
||||
// const std::string data = "0123456789";
|
||||
// DWORD bytes_written = 0;
|
||||
// EXPECT_TRUE(::WriteFile(handle, &data[0],
|
||||
// static_cast<DWORD>(data.size()),
|
||||
// &bytes_written, nullptr));
|
||||
// EXPECT_EQ(10, bytes_written);
|
||||
// EXPECT_TRUE(::CloseHandle(handle));
|
||||
//
|
||||
// if (bytes_written == 10) {
|
||||
// const auto file2 =
|
||||
// utils::path::combine(mount_point, {"test_overwrite2.txt"});
|
||||
// EXPECT_TRUE(::CopyFile(&file[0], &file2[0], TRUE));
|
||||
//
|
||||
// EXPECT_FALSE(::CopyFile(&file[0], &file2[0], TRUE));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
TYPED_TEST_CASE(winfsp_test, winfsp_provider_types);
|
||||
|
||||
@ -234,6 +152,70 @@ TYPED_TEST(winfsp_test, can_write_to_and_read_from_file) {
|
||||
|
||||
this->delete_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, can_rename_file) {
|
||||
std::string file_name{"rename_file"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
auto api_path = utils::path::create_api_path(file_name);
|
||||
|
||||
api_meta_map meta1{};
|
||||
EXPECT_EQ(api_error::success, this->provider->get_item_meta(api_path, meta1));
|
||||
|
||||
auto file_path2 =
|
||||
utils::path::combine(this->mount_location, {file_name + "_2"});
|
||||
auto api_path2 = api_path + "_2";
|
||||
EXPECT_TRUE(::MoveFile(file_path.c_str(), file_path2.c_str()));
|
||||
|
||||
EXPECT_TRUE(utils::file::file(file_path2).exists());
|
||||
EXPECT_FALSE(utils::file::file(file_path).exists());
|
||||
|
||||
api_meta_map meta2{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
this->provider->get_item_meta(api_path2, meta2));
|
||||
EXPECT_STREQ(meta1[META_SOURCE].c_str(), meta2[META_SOURCE].c_str());
|
||||
|
||||
filesystem_item fsi{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
this->provider->get_filesystem_item(api_path2, false, fsi));
|
||||
EXPECT_STREQ(meta1[META_SOURCE].c_str(), fsi.source_path.c_str());
|
||||
|
||||
filesystem_item fsi2{};
|
||||
EXPECT_EQ(api_error::success,
|
||||
this->provider->get_filesystem_item_from_source_path(
|
||||
fsi.source_path, fsi2));
|
||||
EXPECT_STREQ(api_path2.c_str(), fsi2.api_path.c_str());
|
||||
|
||||
EXPECT_EQ(api_error::item_not_found,
|
||||
this->provider->get_item_meta(api_path, meta2));
|
||||
|
||||
this->delete_file_and_test(file_path2);
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, can_rename_directory) {
|
||||
std::string dir_name{"rename_dir"};
|
||||
auto dir_path = this->create_directory_and_test(dir_name);
|
||||
|
||||
auto dir_path2{dir_path + "_2"};
|
||||
|
||||
EXPECT_TRUE(::MoveFileA(dir_path.c_str(), dir_path2.c_str()));
|
||||
EXPECT_FALSE(::PathIsDirectoryA(dir_path.c_str()));
|
||||
EXPECT_TRUE(::PathIsDirectoryA(dir_path2.c_str()));
|
||||
|
||||
this->delete_directory_and_test(dir_path2);
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test, can_overwrite_file) {
|
||||
std::string file_name{"overwrite_file"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
auto file_path2{file_path + "_2"};
|
||||
EXPECT_TRUE(::CopyFile(file_path.c_str(), file_path2.c_str(), TRUE));
|
||||
EXPECT_TRUE(::CopyFile(file_path.c_str(), file_path2.c_str(), FALSE));
|
||||
EXPECT_FALSE(::CopyFile(file_path.c_str(), file_path2.c_str(), TRUE));
|
||||
|
||||
this->delete_file_and_test(file_path);
|
||||
this->delete_file_and_test(file_path2);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // defined(_WIN32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user