file db unit tests and fixes
This commit is contained in:
parent
72fe3613d3
commit
efa5e07549
@ -83,7 +83,8 @@ TYPED_TEST(file_db_test, can_get_api_path_for_file) {
|
|||||||
EXPECT_STREQ("/file", api_path.c_str());
|
EXPECT_STREQ("/file", api_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
TYPED_TEST(file_db_test, item_not_found_is_returned_for_non_existing_api_path) {
|
TYPED_TEST(file_db_test,
|
||||||
|
item_not_found_is_returned_for_non_existing_source_path) {
|
||||||
this->file_db->clear();
|
this->file_db->clear();
|
||||||
|
|
||||||
std::string api_path;
|
std::string api_path;
|
||||||
@ -213,5 +214,119 @@ TYPED_TEST(file_db_test,
|
|||||||
EXPECT_EQ(api_error::item_not_found,
|
EXPECT_EQ(api_error::item_not_found,
|
||||||
this->file_db->get_file_data("/file", data));
|
this->file_db->get_file_data("/file", data));
|
||||||
}
|
}
|
||||||
// test can update file source, iv, size
|
|
||||||
|
TYPED_TEST(file_db_test, can_update_existing_file_iv) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
1U,
|
||||||
|
{{}, {}},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
1U,
|
||||||
|
{{}, {}, {}},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
i_file_db::file_data data{};
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->get_file_data("/file", data));
|
||||||
|
EXPECT_STREQ("/file", data.api_path.c_str());
|
||||||
|
EXPECT_EQ(1U, data.file_size);
|
||||||
|
EXPECT_EQ(3U, data.iv_list.size());
|
||||||
|
EXPECT_STREQ("c:\\test\\file.txt", data.source_path.c_str());
|
||||||
|
|
||||||
|
EXPECT_EQ(1U, this->file_db->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(file_db_test, can_update_existing_file_size) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
1U,
|
||||||
|
{{}, {}},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
2U,
|
||||||
|
{{}, {}},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
i_file_db::file_data data{};
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->get_file_data("/file", data));
|
||||||
|
EXPECT_STREQ("/file", data.api_path.c_str());
|
||||||
|
EXPECT_EQ(2U, data.file_size);
|
||||||
|
EXPECT_EQ(2U, data.iv_list.size());
|
||||||
|
EXPECT_STREQ("c:\\test\\file.txt", data.source_path.c_str());
|
||||||
|
|
||||||
|
EXPECT_EQ(1U, this->file_db->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(file_db_test, can_update_existing_file_source_path) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
1U,
|
||||||
|
{{}, {}},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
1U,
|
||||||
|
{{}, {}},
|
||||||
|
"c:\\test\\file2.txt",
|
||||||
|
}));
|
||||||
|
|
||||||
|
i_file_db::file_data data{};
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->get_file_data("/file", data));
|
||||||
|
EXPECT_STREQ("/file", data.api_path.c_str());
|
||||||
|
EXPECT_EQ(1U, data.file_size);
|
||||||
|
EXPECT_EQ(2U, data.iv_list.size());
|
||||||
|
EXPECT_STREQ("c:\\test\\file2.txt", data.source_path.c_str());
|
||||||
|
|
||||||
|
EXPECT_EQ(1U, this->file_db->count());
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(file_db_test, can_get_source_path_for_directory) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_directory("/", "c:\\test"));
|
||||||
|
std::string source_path;
|
||||||
|
EXPECT_EQ(api_error::success,
|
||||||
|
this->file_db->get_source_path("/", source_path));
|
||||||
|
EXPECT_STREQ("c:\\test", source_path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(file_db_test, can_get_source_path_for_file) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
EXPECT_EQ(api_error::success, this->file_db->add_or_update_file({
|
||||||
|
"/file",
|
||||||
|
0U,
|
||||||
|
{},
|
||||||
|
"c:\\test\\file.txt",
|
||||||
|
}));
|
||||||
|
std::string source_path;
|
||||||
|
EXPECT_EQ(api_error::success,
|
||||||
|
this->file_db->get_source_path("/file", source_path));
|
||||||
|
EXPECT_STREQ("c:\\test\\file.txt", source_path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
TYPED_TEST(file_db_test, item_not_found_is_returned_for_non_existing_api_path) {
|
||||||
|
this->file_db->clear();
|
||||||
|
|
||||||
|
std::string source_path;
|
||||||
|
EXPECT_EQ(api_error::item_not_found,
|
||||||
|
this->file_db->get_source_path("/file", source_path));
|
||||||
|
EXPECT_TRUE(source_path.empty());
|
||||||
|
}
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user