#include #include #include "accountservice.h" #include "accountdao.h" #include "databasemanager.h" #include "account.h" int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); // Ensure DB is initialized DatabaseManager::instance().database(); AccountService service; // Create a test account Account testAcc; testAcc.setEmail("test_delete@example.com"); testAcc.setDisplayName("Test Delete"); testAcc.setType(AccountType::IMAP); Account::ConnectionSettings settings; settings.incomingHost = "imap.example.com"; settings.incomingPort = 993; settings.incomingSsl = true; settings.outgoingHost = "smtp.example.com"; settings.outgoingPort = 465; settings.outgoingSsl = true; settings.username = "testdelete@example.com"; settings.password = "testpass"; settings.authMethod = "LOGIN"; testAcc.setConnectionSettings(settings); qDebug() << "Adding test account..."; service.addAccount(testAcc); qint64 addedId = testAcc.id(); qDebug() << "Added account ID:" << addedId; // Verify exists QVector accounts = AccountDao::findAll(); bool found = false; for (const Account &acc : accounts) { if (acc.email() == "test_delete@example.com") { found = true; qDebug() << "Found account after add, ID:" << acc.id(); break; } } if (!found) { qWarning() << "Account not found after add!"; return 1; } // Remove account qDebug() << "Removing account ID:" << addedId; service.removeAccount(addedId); // Verify removed accounts = AccountDao::findAll(); bool stillThere = false; for (const Account &acc : accounts) { if (acc.email() == "test_delete@example.com") { stillThere = true; qDebug() << "Account still present after removal!"; break; } } if (stillThere) { qWarning() << "FAIL: Account still present after removal."; return 1; } else { qDebug() << "SUCCESS: Account removed successfully."; return 0; } }