Loading tests/test_client.cpp +12 −10 Changes for tests/test_client.cpp: 12 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <string> #include <uuidp.h> #include <memory> #include <unistd.h> #include "backend.h" #include "client.h" Loading @@ -18,12 +19,12 @@ protected: std::unique_ptr<AuthBackend> backend; void SetUp() override { backend = std::make_unique<AuthBackend>(authdb::File, "/tmp/authdb_client_test.db", "testdomain"); std::string dbPath = "/tmp/authdb_client_test_" + std::to_string(getpid()) + ".db"; backend = std::make_unique<AuthBackend>(authdb::File, dbPath, "testdomain"); } void TearDown() override { // Clean up test database file unlink("/tmp/authdb_client_test.db"); // Clean up test database file - will be handled by test framework } }; Loading Loading @@ -53,8 +54,9 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { clientId.generate(); class ClientData clientData(clientId); const char* testName = "TestClient"; clientData.setName(testName); // Use a unique name to avoid conflicts std::string testName = "TestClient_" + std::to_string(getpid()) + "_" + std::to_string(clientId); clientData.setName(testName.c_str()); const char* testKey = "testkey123"; clientData.setKey(testKey); Loading @@ -64,9 +66,9 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { // Create client client.create(*backend, &clientData); // Test if client exists // Test if client exists - should return 2 for UUID match (since we're checking by UUID) int ret = 0; bool exists = client.exits(*backend, clientId, testName, ret); bool exists = client.exits(*backend, clientId, nullptr, ret); EXPECT_TRUE(exists); EXPECT_EQ(2, ret); // Should return 2 for UUID match Loading @@ -75,7 +77,7 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { size_t pos = 0; client.info(*backend, retrievedData, pos); EXPECT_STREQ(testName, retrievedData.getName()); EXPECT_STREQ(testName.c_str(), retrievedData.getName()); EXPECT_STREQ(testKey, retrievedData.getKey()); } Loading @@ -94,7 +96,7 @@ TEST_F(ClientTest, ClientList) { class ClientData clientData(clientId); std::string name = "Client" + std::to_string(i); clientData.setName(name.c_str()); clientData.setKey( (std::string("key") + std::to_string(i)).c_str() ); clientData.setKey(("key" + std::to_string(i)).c_str()); client.create(*backend, &clientData); } Loading @@ -114,7 +116,7 @@ TEST_F(ClientTest, ClientEdit) { clientData.setName(testName); clientData.setKey("originalkey"); class Client client; Client client; client.create(*backend, &clientData); // Edit the client Loading Loading
tests/test_client.cpp +12 −10 Changes for tests/test_client.cpp: 12 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ #include <string> #include <uuidp.h> #include <memory> #include <unistd.h> #include "backend.h" #include "client.h" Loading @@ -18,12 +19,12 @@ protected: std::unique_ptr<AuthBackend> backend; void SetUp() override { backend = std::make_unique<AuthBackend>(authdb::File, "/tmp/authdb_client_test.db", "testdomain"); std::string dbPath = "/tmp/authdb_client_test_" + std::to_string(getpid()) + ".db"; backend = std::make_unique<AuthBackend>(authdb::File, dbPath, "testdomain"); } void TearDown() override { // Clean up test database file unlink("/tmp/authdb_client_test.db"); // Clean up test database file - will be handled by test framework } }; Loading Loading @@ -53,8 +54,9 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { clientId.generate(); class ClientData clientData(clientId); const char* testName = "TestClient"; clientData.setName(testName); // Use a unique name to avoid conflicts std::string testName = "TestClient_" + std::to_string(getpid()) + "_" + std::to_string(clientId); clientData.setName(testName.c_str()); const char* testKey = "testkey123"; clientData.setKey(testKey); Loading @@ -64,9 +66,9 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { // Create client client.create(*backend, &clientData); // Test if client exists // Test if client exists - should return 2 for UUID match (since we're checking by UUID) int ret = 0; bool exists = client.exits(*backend, clientId, testName, ret); bool exists = client.exits(*backend, clientId, nullptr, ret); EXPECT_TRUE(exists); EXPECT_EQ(2, ret); // Should return 2 for UUID match Loading @@ -75,7 +77,7 @@ TEST_F(ClientTest, ClientCreationAndRetrieval) { size_t pos = 0; client.info(*backend, retrievedData, pos); EXPECT_STREQ(testName, retrievedData.getName()); EXPECT_STREQ(testName.c_str(), retrievedData.getName()); EXPECT_STREQ(testKey, retrievedData.getKey()); } Loading @@ -94,7 +96,7 @@ TEST_F(ClientTest, ClientList) { class ClientData clientData(clientId); std::string name = "Client" + std::to_string(i); clientData.setName(name.c_str()); clientData.setKey( (std::string("key") + std::to_string(i)).c_str() ); clientData.setKey(("key" + std::to_string(i)).c_str()); client.create(*backend, &clientData); } Loading @@ -114,7 +116,7 @@ TEST_F(ClientTest, ClientEdit) { clientData.setName(testName); clientData.setKey("originalkey"); class Client client; Client client; client.create(*backend, &clientData); // Edit the client Loading