mirror of
https://github.com/redstrate/Astra.git
synced 2025-06-07 22:47:46 +00:00
Begin testing AccountManager
This commit is contained in:
parent
51d9551667
commit
33441f06d0
3 changed files with 40 additions and 1 deletions
|
@ -1,6 +1,12 @@
|
||||||
# SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
# SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
ecm_add_test(accountmanagertest.cpp
|
||||||
|
TEST_NAME accountmanagertest
|
||||||
|
LINK_LIBRARIES astra_static Qt::Test
|
||||||
|
NAME_PREFIX "astra-"
|
||||||
|
)
|
||||||
|
|
||||||
ecm_add_test(patchlisttest.cpp
|
ecm_add_test(patchlisttest.cpp
|
||||||
TEST_NAME patchlisttest
|
TEST_NAME patchlisttest
|
||||||
LINK_LIBRARIES astra_static Qt::Test
|
LINK_LIBRARIES astra_static Qt::Test
|
||||||
|
|
33
autotests/accountmanagertest.cpp
Normal file
33
autotests/accountmanagertest.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#include "accountmanager.h"
|
||||||
|
|
||||||
|
class AccountManagerTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void testNothing()
|
||||||
|
{
|
||||||
|
AccountManager profileManager;
|
||||||
|
QAbstractItemModelTester modelTester(&profileManager);
|
||||||
|
|
||||||
|
QCOMPARE(profileManager.rowCount({}), 0);
|
||||||
|
profileManager.load();
|
||||||
|
|
||||||
|
// There should be no profiles, not even a dummy one
|
||||||
|
QCOMPARE(profileManager.rowCount({}), 0);
|
||||||
|
QCOMPARE(profileManager.numAccounts(), 0);
|
||||||
|
QVERIFY(!profileManager.hasAnyAccounts());
|
||||||
|
|
||||||
|
// These functions shouldn't crash and return empty when there's no acccounts
|
||||||
|
QCOMPARE(profileManager.getByUuid(QString{}), nullptr);
|
||||||
|
QVERIFY(!profileManager.canDelete(nullptr));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
QTEST_MAIN(AccountManagerTest)
|
||||||
|
#include "accountmanagertest.moc"
|
|
@ -92,7 +92,7 @@ Account *AccountManager::getByUuid(const QString &uuid) const
|
||||||
bool AccountManager::canDelete(const Account *account) const
|
bool AccountManager::canDelete(const Account *account) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(account)
|
Q_UNUSED(account)
|
||||||
return m_accounts.size() != 1;
|
return m_accounts.size() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccountManager::deleteAccount(Account *account)
|
void AccountManager::deleteAccount(Account *account)
|
||||||
|
|
Loading…
Add table
Reference in a new issue