Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3354205
D3161.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3161.diff
View Options
diff --git a/services/backup/docker-server/contents/server/CMakeLists.txt b/services/backup/docker-server/contents/server/CMakeLists.txt
--- a/services/backup/docker-server/contents/server/CMakeLists.txt
+++ b/services/backup/docker-server/contents/server/CMakeLists.txt
@@ -27,6 +27,10 @@
set(gRPC_BUILD_GRPC_PYTHON_PLUGIN OFF)
set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF)
+if ($ENV{COMM_TEST_SERVICES} MATCHES 1)
+ add_compile_definitions(COMM_TEST_SERVICES)
+endif()
+
# Find gRPC installation
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
find_package(gRPC CONFIG REQUIRED)
diff --git a/services/backup/docker-server/contents/server/test/DatabaseManagerTest.cpp b/services/backup/docker-server/contents/server/test/DatabaseManagerTest.cpp
new file mode 100644
--- /dev/null
+++ b/services/backup/docker-server/contents/server/test/DatabaseManagerTest.cpp
@@ -0,0 +1,58 @@
+#include <gtest/gtest.h>
+
+#include "DatabaseManager.h"
+#include "Tools.h"
+
+#include <iostream>
+
+#include <memory>
+#include <string>
+#include <vector>
+
+using namespace comm::network::database;
+
+class DatabaseManagerTest : public testing::Test {
+protected:
+ virtual void SetUp() {
+ Aws::InitAPI({});
+ }
+
+ virtual void TearDown() {
+ Aws::ShutdownAPI({});
+ }
+};
+
+std::string generateName(const std::string prefix = "") {
+ return prefix + "-" + std::to_string(comm::network::getCurrentTimestamp());
+}
+
+TEST_F(DatabaseManagerTest, TestOperationsOnBackupItems) {
+ auto generateBackupItem = [](const std::string &userID,
+ const std::string &backupID) {
+ return BackupItem(
+ userID,
+ backupID,
+ comm::network::getCurrentTimestamp(),
+ "xxx",
+ "xxx",
+ {""});
+ };
+
+ const std::string userID = generateName("user001");
+
+ std::vector<std::string> backupIDs = {"backup001", "backup002", "backup003"};
+ for (const std::string &backupID : backupIDs) {
+ DatabaseManager::getInstance().putBackupItem(
+ generateBackupItem(userID, backupID));
+ }
+
+ std::shared_ptr<BackupItem> item;
+ while (!backupIDs.empty()) {
+ item = DatabaseManager::getInstance().findLastBackupItem(userID);
+ EXPECT_NE(item, nullptr);
+ EXPECT_EQ(item->getBackupID(), backupIDs.back());
+ backupIDs.pop_back();
+ DatabaseManager::getInstance().removeBackupItem(item);
+ };
+ EXPECT_EQ(DatabaseManager::getInstance().findLastBackupItem(userID), nullptr);
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 12:22 PM (18 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575544
Default Alt Text
D3161.diff (2 KB)
Attached To
Mode
D3161: [services] Backup - Add DB test for Backup
Attached
Detach File
Event Timeline
Log In to Comment