forked from ondra/server-sdk
fixing unittests ( using guiless app )
This commit is contained in:
parent
30925777b4
commit
174ede92ee
@ -140,6 +140,11 @@ QSqlQuery DatabaseUtils::insertIntoTable(const DatabaseTable *table, const QStri
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DatabaseUtils::udpateFromSqlQuery(DatabaseTable *table, QSqlQuery query) const
|
||||||
|
{
|
||||||
|
qCDebug(sdkdb) << "not implemented";
|
||||||
|
}
|
||||||
|
|
||||||
QString DatabaseUtils::sqlType() const
|
QString DatabaseUtils::sqlType() const
|
||||||
{
|
{
|
||||||
return mSqlType;
|
return mSqlType;
|
||||||
|
|||||||
@ -22,6 +22,8 @@ public:
|
|||||||
QSqlQuery createTable(const DatabaseTable *table, const QString table_name) const;
|
QSqlQuery createTable(const DatabaseTable *table, const QString table_name) const;
|
||||||
|
|
||||||
QSqlQuery insertIntoTable(const DatabaseTable *table, const QString table_name) const;
|
QSqlQuery insertIntoTable(const DatabaseTable *table, const QString table_name) const;
|
||||||
|
void udpateFromSqlQuery(DatabaseTable *table, QSqlQuery query) const;
|
||||||
|
|
||||||
|
|
||||||
QString sqlType() const;
|
QString sqlType() const;
|
||||||
void setSqlType(const QString &sqlType);
|
void setSqlType(const QString &sqlType);
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
class BookTable : public serversdk::DatabaseTable
|
class BookTable : public serversdk::DatabaseTable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_CLASSINFO("default_table", "books")
|
|
||||||
TABLE_PROPERTY(QUuid, id, set_id, QUuid());
|
TABLE_PROPERTY(QUuid, id, set_id, QUuid());
|
||||||
TABLE_PROPERTY(QString, description, set_description, "");
|
TABLE_PROPERTY(QString, description, set_description, "");
|
||||||
TABLE_PROPERTY(QDateTime, last_update, set_last_update, QDateTime::fromSecsSinceEpoch(0));
|
TABLE_PROPERTY(QDateTime, last_update, set_last_update, QDateTime::fromSecsSinceEpoch(0));
|
||||||
|
|||||||
@ -91,11 +91,11 @@ void SqliteTest::createTable_test()
|
|||||||
QSqlQuery insertQuery = utils.insertIntoTable(names.get(), "names");
|
QSqlQuery insertQuery = utils.insertIntoTable(names.get(), "names");
|
||||||
//Q_ASSERT(insertQuery.isValid());
|
//Q_ASSERT(insertQuery.isValid());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Select from table
|
// Select from table
|
||||||
QSqlQuery selectSQL("SELECT * FROM names");
|
QSqlQuery selectSQL("SELECT * FROM names");
|
||||||
// Q_ASSERT(db.executeQuery(selectSQL));
|
|
||||||
|
// TODO: finish -> have to use sqlPlain
|
||||||
|
// Q_ASSERT(db.executeQselectSQL));
|
||||||
while (selectSQL.next()) {
|
while (selectSQL.next()) {
|
||||||
QString value = selectSQL.value(1).toString();
|
QString value = selectSQL.value(1).toString();
|
||||||
qDebug() << "value is" << value;
|
qDebug() << "value is" << value;
|
||||||
|
|||||||
@ -54,37 +54,14 @@ void RequestManagerTest::colnodAuthorization_test()
|
|||||||
|
|
||||||
|
|
||||||
Token token;
|
Token token;
|
||||||
|
QVERIFY(token.id().isNull()); // must be null
|
||||||
token.fromJson(data);
|
token.fromJson(data);
|
||||||
|
QVERIFY(!token.id().isNull()); // mut not be null ( authentication token )
|
||||||
qDebug() << "token is" << token.id();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
qDebug() << "repsonse data:" << loginRequest->responseData();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (loginRequest->networkReply()->error()) {
|
|
||||||
qDebug() << "error for reply:" << loginRequest->networkReply()->errorString();
|
|
||||||
if (!loginRequest->responseData().isEmpty() && !loginRequest->responseData().contains("error")){
|
|
||||||
auto jsonDoc = QJsonDocument::fromJson(loginRequest->responseData());
|
|
||||||
QString token = jsonDoc.object()["id"].toString();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
qDebug() << "Login failed.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(serversdk::RequestManagerTest)
|
QTEST_GUILESS_MAIN(serversdk::RequestManagerTest)
|
||||||
|
|
||||||
#include "tst_requestmanager.moc"
|
#include "tst_requestmanager.moc"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user