Made tests for features of 59344e6
This commit is contained in:
parent
59344e6464
commit
42bf5da2a3
1 changed files with 26 additions and 1 deletions
|
|
@ -13,6 +13,7 @@ private:
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
User sampleUser;
|
User sampleUser;
|
||||||
|
Profession sampleProfession;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iFacilityTest() = default;
|
iFacilityTest() = default;
|
||||||
|
|
@ -29,6 +30,9 @@ private slots:
|
||||||
void test_db_get_user_by_login();
|
void test_db_get_user_by_login();
|
||||||
void test_db_get_users_by_type();
|
void test_db_get_users_by_type();
|
||||||
void test_db_get_users_gy_profession();
|
void test_db_get_users_gy_profession();
|
||||||
|
void test_db_remove_dependant_profession();
|
||||||
|
void test_db_remove_user();
|
||||||
|
void test_db_remove_independant_profession();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,10 +162,31 @@ void iFacilityTest::test_db_get_users_gy_profession() {
|
||||||
auto usr1 = Database::instance()->getUser(sampleUser.getLogin());
|
auto usr1 = Database::instance()->getUser(sampleUser.getLogin());
|
||||||
Profession p = Profession::createProfession("test_prof");
|
Profession p = Profession::createProfession("test_prof");
|
||||||
usr1->addProfession(p, 3);
|
usr1->addProfession(p, 3);
|
||||||
auto usrs = Database::instance()->getUsersByProfession(p);
|
|
||||||
|
QVERIFY(Database::instance()->addProfession(p));
|
||||||
|
|
||||||
|
auto usrs = Database::instance()->getUsersByProfession(p.pID());
|
||||||
|
|
||||||
QVERIFY(usrs.size() == 1);
|
QVERIFY(usrs.size() == 1);
|
||||||
QVERIFY(usr1 == usrs[0]);
|
QVERIFY(usr1 == usrs[0]);
|
||||||
|
|
||||||
|
sampleProfession = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_remove_dependant_profession() {
|
||||||
|
QVERIFY(!Database::instance()->removeProfession(sampleProfession.pID()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_remove_user() {
|
||||||
|
QVERIFY(Database::instance()->removeUser(sampleUser.uID()));
|
||||||
|
UID nonExistentUuid = 0;
|
||||||
|
QVERIFY(!Database::instance()->removeUser(nonExistentUuid));
|
||||||
|
}
|
||||||
|
|
||||||
|
void iFacilityTest::test_db_remove_independant_profession() {
|
||||||
|
QVERIFY(Database::instance()->removeProfession(sampleProfession.pID()));
|
||||||
|
PID nonExistentPuid = 0;
|
||||||
|
QVERIFY(!Database::instance()->removeProfession(nonExistentPuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_APPLESS_MAIN(iFacilityTest)
|
QTEST_APPLESS_MAIN(iFacilityTest)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue