mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-27 10:14:36 +00:00
try fix single server test
This commit is contained in:
parent
93f7abe6fa
commit
d2441157aa
@ -107,7 +107,7 @@ bool DataBaseNode::run(const QString &addres,
|
||||
if (localNodeName.isEmpty())
|
||||
return false;
|
||||
|
||||
_localNodeName = localNodeName;
|
||||
setLocalNodeName(localNodeName);
|
||||
|
||||
if (!isSqlInited() && !initSqlDb()) {
|
||||
return false;
|
||||
@ -450,6 +450,10 @@ bool DataBaseNode::upgradeDataBase() {
|
||||
return true;
|
||||
}
|
||||
|
||||
const QString &DataBaseNode::localNodeName() const {
|
||||
return _localNodeName;
|
||||
}
|
||||
|
||||
void DataBaseNode::setLocalNodeName(const QString &newLocalNodeName) {
|
||||
_localNodeName = newLocalNodeName;
|
||||
}
|
||||
@ -458,7 +462,7 @@ QVariantMap DataBaseNode::defaultDbParams() const {
|
||||
|
||||
return {
|
||||
{"DBDriver", "QSQLITE"},
|
||||
{"DBFilePath", DEFAULT_DB_PATH + "/" + _localNodeName + "/" + _localNodeName + "_" + DEFAULT_DB_NAME},
|
||||
{"DBFilePath", DEFAULT_DB_PATH + "/" + localNodeName() + "/" + localNodeName() + "_" + DEFAULT_DB_NAME},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -205,8 +205,16 @@ public:
|
||||
const std::function<bool (const QSharedPointer<QH::PKG::DBObject>&)> &changeAction);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* @brief localNodeName This method return local node name.
|
||||
*
|
||||
* @return local node name
|
||||
*/
|
||||
const QString &localNodeName() const;
|
||||
|
||||
/**
|
||||
* @brief setLocalNodeName This method sets new local name of database file.
|
||||
* @note This method must be invoked before the DataBaseNode::initsqlDb and the DataBaseNode::run methods.
|
||||
|
@ -393,6 +393,13 @@ ErrorCodes::Code SingleClient::getLastError() const {
|
||||
return _lastError;
|
||||
}
|
||||
|
||||
ErrorCodes::Code SingleClient::takeLastError() {
|
||||
auto result = _lastError;
|
||||
setLastError(ErrorCodes::NoError);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QString SingleClient::getLastErrorString() const {
|
||||
return ErrorCodes::DBErrorCodesHelper::toString(_lastError);
|
||||
}
|
||||
|
@ -132,6 +132,12 @@ public:
|
||||
*/
|
||||
ErrorCodes::Code getLastError() const;
|
||||
|
||||
/**
|
||||
* @brief takeLastError This method take last erro code. after call this object sets no error to last error.
|
||||
* @return LastError code.
|
||||
*/
|
||||
ErrorCodes::Code takeLastError();
|
||||
|
||||
/**
|
||||
* @brief getLastErrorString This method return the string implementation of a last code error.
|
||||
* @return string value of the last error.
|
||||
|
@ -46,11 +46,13 @@ TestUtils::~TestUtils() {
|
||||
|
||||
bool TestUtils::wait(const std::function<bool()> &forWait, int msec) const {
|
||||
auto curmsec = QDateTime::currentMSecsSinceEpoch() + msec;
|
||||
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !forWait()) {
|
||||
bool waitFor = false;
|
||||
while (curmsec > QDateTime::currentMSecsSinceEpoch() && !waitFor) {
|
||||
waitFor = forWait();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
QCoreApplication::processEvents();
|
||||
return forWait();
|
||||
return waitFor;
|
||||
}
|
||||
|
||||
bool TestUtils::connectFunc(
|
||||
|
@ -85,19 +85,19 @@ void SingleServerTest::loginTest() {
|
||||
};
|
||||
|
||||
auto checkLoginNonExitsUser = [client](){
|
||||
return client->getLastError() == static_cast<int>(QH::ErrorCodes::UserNotExits);
|
||||
return client->takeLastError() == static_cast<int>(QH::ErrorCodes::UserNotExits);
|
||||
};
|
||||
|
||||
auto checksigupExitsUser = [client](){
|
||||
return client->getLastError() == static_cast<int>(QH::ErrorCodes::UserExits);
|
||||
return client->takeLastError() == static_cast<int>(QH::ErrorCodes::UserExits);
|
||||
};
|
||||
|
||||
auto checkLoginInvalidPassword = [client](){
|
||||
return client->getLastError() == static_cast<int>(QH::ErrorCodes::UserInvalidPasswoed);
|
||||
return client->takeLastError() == static_cast<int>(QH::ErrorCodes::UserInvalidPasswoed);
|
||||
};
|
||||
|
||||
auto checkRemoveNotLoginningClient = [client](){
|
||||
return client->getLastError() == static_cast<int>(QH::ErrorCodes::UserNotLogged);
|
||||
return client->takeLastError() == static_cast<int>(QH::ErrorCodes::UserNotLogged);
|
||||
};
|
||||
|
||||
QVERIFY(client && server);
|
||||
|
Loading…
x
Reference in New Issue
Block a user